<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- (c) The University of Glasgow 2006</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP, FlexibleInstances #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# OPTIONS_GHC -fno-warn-orphans #-}</span><span>  </span><span class="hs-comment">-- instance MonadThings is necessarily an</span><span>
</span><span id="line-5"></span><span>                                       </span><span class="hs-comment">-- orphan</span><span>
</span><span id="line-6"></span><span class="hs-pragma">{-# LANGUAGE UndecidableInstances #-}</span><span> </span><span class="hs-comment">-- Wrinkle in Note [Trees That Grow]</span><span>
</span><span id="line-7"></span><span>                                      </span><span class="hs-comment">-- in module GHC.Hs.Extension</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span>
</span><span id="line-9"></span><span>
</span><span id="line-10"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.Utils.Env</span><span class="hs-special">(</span><span>
</span><span id="line-11"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier">TyThing</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTyThing"><span class="hs-identifier">TcTyThing</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier">TcId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span>        </span><span class="hs-comment">-- Instance environment, and InstInfo type</span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier">InstInfo</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#iDFunId"><span class="hs-identifier">iDFunId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#pprInstInfoDetails"><span class="hs-identifier">pprInstInfoDetails</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#simpleInstInfoClsTy"><span class="hs-identifier">simpleInstInfoClsTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#simpleInstInfoTy"><span class="hs-identifier">simpleInstInfoTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#simpleInstInfoTyCon"><span class="hs-identifier">simpleInstInfoTyCon</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier">InstBindings</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span>        </span><span class="hs-comment">-- Global environment</span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnv"><span class="hs-identifier">tcExtendGlobalEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendTyConEnv"><span class="hs-identifier">tcExtendTyConEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnvImplicit"><span class="hs-identifier">tcExtendGlobalEnvImplicit</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#setGlobalTypeEnv"><span class="hs-identifier">setGlobalTypeEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalValEnv"><span class="hs-identifier">tcExtendGlobalValEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedGlobal"><span class="hs-identifier">tcLookupLocatedGlobal</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier">tcLookupGlobal</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupGlobalOnly"><span class="hs-identifier">tcLookupGlobalOnly</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupTyCon"><span class="hs-identifier">tcLookupTyCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupClass"><span class="hs-identifier">tcLookupClass</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupDataCon"><span class="hs-identifier">tcLookupDataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupPatSyn"><span class="hs-identifier">tcLookupPatSyn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupConLike"><span class="hs-identifier">tcLookupConLike</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedGlobalId"><span class="hs-identifier">tcLookupLocatedGlobalId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedTyCon"><span class="hs-identifier">tcLookupLocatedTyCon</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedClass"><span class="hs-identifier">tcLookupLocatedClass</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupAxiom"><span class="hs-identifier">tcLookupAxiom</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#lookupGlobal"><span class="hs-identifier">lookupGlobal</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#ioLookupDataCon"><span class="hs-identifier">ioLookupDataCon</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#addTypecheckedBinds"><span class="hs-identifier">addTypecheckedBinds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span>        </span><span class="hs-comment">-- Local environment</span><span>
</span><span id="line-31"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendKindEnv"><span class="hs-identifier">tcExtendKindEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendKindEnvList"><span class="hs-identifier">tcExtendKindEnvList</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendTyVarEnv"><span class="hs-identifier">tcExtendTyVarEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendNameTyVarEnv"><span class="hs-identifier">tcExtendNameTyVarEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendLetEnv"><span class="hs-identifier">tcExtendLetEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendSigIds"><span class="hs-identifier">tcExtendSigIds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendRecIds"><span class="hs-identifier">tcExtendRecIds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv"><span class="hs-identifier">tcExtendIdEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv1"><span class="hs-identifier">tcExtendIdEnv1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv2"><span class="hs-identifier">tcExtendIdEnv2</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendBinderStack"><span class="hs-identifier">tcExtendBinderStack</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendLocalTypeEnv"><span class="hs-identifier">tcExtendLocalTypeEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#isTypeClosedLetBndr"><span class="hs-identifier">isTypeClosedLetBndr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcCheckUsage"><span class="hs-identifier">tcCheckUsage</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookup"><span class="hs-identifier">tcLookup</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocated"><span class="hs-identifier">tcLookupLocated</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocalIds"><span class="hs-identifier">tcLookupLocalIds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupId"><span class="hs-identifier">tcLookupId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupIdMaybe"><span class="hs-identifier">tcLookupIdMaybe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupTyVar"><span class="hs-identifier">tcLookupTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupTcTyCon"><span class="hs-identifier">tcLookupTcTyCon</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLcl_maybe"><span class="hs-identifier">tcLookupLcl_maybe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#getInLocalScope"><span class="hs-identifier">getInLocalScope</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#wrongThingErr"><span class="hs-identifier">wrongThingErr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#pprBinders"><span class="hs-identifier">pprBinders</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcAddDataFamConPlaceholders"><span class="hs-identifier">tcAddDataFamConPlaceholders</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcAddPatSynPlaceholders"><span class="hs-identifier">tcAddPatSynPlaceholders</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-47"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#getTypeSigNames"><span class="hs-identifier">getTypeSigNames</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-48"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendRecEnv"><span class="hs-identifier">tcExtendRecEnv</span></a></span><span class="hs-special">,</span><span>         </span><span class="hs-comment">-- For knot-tying</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span>        </span><span class="hs-comment">-- Tidying</span><span>
</span><span id="line-51"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcInitTidyEnv"><span class="hs-identifier">tcInitTidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcInitOpenTidyEnv"><span class="hs-identifier">tcInitOpenTidyEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span>        </span><span class="hs-comment">-- Instances</span><span>
</span><span id="line-54"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupInstance"><span class="hs-identifier">tcLookupInstance</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcGetInstEnvs"><span class="hs-identifier">tcGetInstEnvs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span>        </span><span class="hs-comment">-- Rules</span><span>
</span><span id="line-57"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendRules"><span class="hs-identifier">tcExtendRules</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-58"></span><span>
</span><span id="line-59"></span><span>        </span><span class="hs-comment">-- Defaults</span><span>
</span><span id="line-60"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcGetDefaultTys"><span class="hs-identifier">tcGetDefaultTys</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span>        </span><span class="hs-comment">-- Template Haskell stuff</span><span>
</span><span id="line-63"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#checkWellStaged"><span class="hs-identifier">checkWellStaged</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcMetaTy"><span class="hs-identifier">tcMetaTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#thLevel"><span class="hs-identifier">thLevel</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-64"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#topIdLvl"><span class="hs-identifier">topIdLvl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#isBrackStage"><span class="hs-identifier">isBrackStage</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span>        </span><span class="hs-comment">-- New Ids</span><span>
</span><span id="line-67"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#newDFunName"><span class="hs-identifier">newDFunName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#newFamInstTyConName"><span class="hs-identifier">newFamInstTyConName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-68"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#newFamInstAxiomName"><span class="hs-identifier">newFamInstAxiomName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-69"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#mkStableIdFromString"><span class="hs-identifier">mkStableIdFromString</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#mkStableIdFromName"><span class="hs-identifier">mkStableIdFromName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-70"></span><span>        </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#mkWrapperName"><span class="hs-identifier">mkWrapperName</span></a></span><span>
</span><span id="line-71"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.html"><span class="hs-identifier">GHC.Hs</span></a></span><span>
</span><span id="line-78"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Iface.Env.html"><span class="hs-identifier">GHC.Iface.Env</span></a></span><span>
</span><span id="line-79"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-80"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html"><span class="hs-identifier">GHC.Tc.Utils.TcMType</span></a></span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.UsageEnv.html"><span class="hs-identifier">GHC.Core.UsageEnv</span></a></span><span>
</span><span id="line-83"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html"><span class="hs-identifier">GHC.Tc.Types.Evidence</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier">idHsWrapper</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-84"></span><span class="hs-keyword">import</span><span> </span><span class="hs-pragma">{-# SOURCE</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html"><span class="hs-identifier">GHC.Tc.Utils.Unify</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#tcSubMult"><span class="hs-identifier">tcSubMult</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html"><span class="hs-identifier">GHC.Tc.Types.Origin</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier">CtOrigin</span></a></span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UsageEnvironmentOf"><span class="hs-identifier">UsageEnvironmentOf</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Iface.Load.html"><span class="hs-identifier">GHC.Iface.Load</span></a></span><span>
</span><span id="line-87"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span>
</span><span id="line-88"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>
</span><span id="line-89"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-90"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-91"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html"><span class="hs-identifier">GHC.Types.Name.Reader</span></a></span><span>
</span><span id="line-92"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html"><span class="hs-identifier">GHC.Core.InstEnv</span></a></span><span>
</span><span id="line-93"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier">DataCon</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-94"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.PatSyn.html"><span class="hs-identifier">GHC.Core.PatSyn</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.PatSyn.html#PatSyn"><span class="hs-identifier">PatSyn</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-95"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html"><span class="hs-identifier">GHC.Core.ConLike</span></a></span><span>
</span><span id="line-96"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-97"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-98"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html"><span class="hs-identifier">GHC.Core.Coercion.Axiom</span></a></span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Class.html"><span class="hs-identifier">GHC.Core.Class</span></a></span><span>
</span><span id="line-101"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-102"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html"><span class="hs-identifier">GHC.Types.Name.Set</span></a></span><span>
</span><span id="line-103"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Env.html"><span class="hs-identifier">GHC.Types.Name.Env</span></a></span><span>
</span><span id="line-104"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-105"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html"><span class="hs-identifier">GHC.Driver.Types</span></a></span><span>
</span><span id="line-106"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-107"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html"><span class="hs-identifier">GHC.Types.SrcLoc</span></a></span><span>
</span><span id="line-108"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span> </span><span class="hs-keyword">hiding</span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SuccessFlag"><span class="hs-identifier">SuccessFlag</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html"><span class="hs-identifier">GHC.Unit.Module</span></a></span><span>
</span><span id="line-110"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-111"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Encoding.html"><span class="hs-identifier">GHC.Utils.Encoding</span></a></span><span>
</span><span id="line-112"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-113"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-114"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.List.SetOps.html"><span class="hs-identifier">GHC.Data.List.SetOps</span></a></span><span>
</span><span id="line-115"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>
</span><span id="line-116"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html#MaybeErr"><span class="hs-identifier">MaybeErr</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html#orElse"><span class="hs-identifier">orElse</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-117"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-118"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier">HasDebugCallStack</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.IORef.html#"><span class="hs-identifier">Data.IORef</span></a></span><span>
</span><span id="line-121"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.OldList.html#intercalate"><span class="hs-identifier">intercalate</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-123"></span><span>
</span><span id="line-124"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
            An IO interface to looking up globals
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#lookupGlobal"><span class="hs-identifier hs-type">lookupGlobal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span>
</span><span id="line-131"></span><span class="hs-comment">-- A variant of lookupGlobal_maybe for the clients which are not</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- interested in recovering from lookup failure and accept panic.</span><span>
</span><span id="line-133"></span><span id="lookupGlobal"><span class="annot"><span class="annottext">lookupGlobal :: HscEnv -&gt; Name -&gt; IO TyThing
</span><a href="GHC.Tc.Utils.Env.html#lookupGlobal"><span class="hs-identifier hs-var hs-var">lookupGlobal</span></a></span></span><span> </span><span id="local-6989586621681083704"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083704"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span> </span><span id="local-6989586621681083703"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083703"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-134"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span>
</span><span id="line-135"></span><span>          </span><span id="local-6989586621681083702"><span class="annot"><span class="annottext">MaybeErr MsgDoc TyThing
</span><a href="#local-6989586621681083702"><span class="hs-identifier hs-var">mb_thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; Name -&gt; IO (MaybeErr MsgDoc TyThing)
</span><a href="GHC.Tc.Utils.Env.html#lookupGlobal_maybe"><span class="hs-identifier hs-var">lookupGlobal_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083704"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083703"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-136"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MaybeErr MsgDoc TyThing
</span><a href="#local-6989586621681083702"><span class="hs-identifier hs-var">mb_thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-137"></span><span>            </span><span class="annot"><a href="GHC.Data.Maybe.html#Succeeded"><span class="hs-identifier hs-type">Succeeded</span></a></span><span> </span><span id="local-6989586621681083699"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083699"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyThing -&gt; IO TyThing
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083699"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-138"></span><span>            </span><span class="annot"><a href="GHC.Data.Maybe.html#Failed"><span class="hs-identifier hs-type">Failed</span></a></span><span> </span><span id="local-6989586621681083697"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083697"><span class="hs-identifier hs-var">msg</span></a></span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IO TyThing
forall a. HasCallStack =&gt; String -&gt; MsgDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupGlobal&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083697"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-139"></span><span>        </span><span class="hs-special">}</span><span>
</span><span id="line-140"></span><span>
</span><span id="line-141"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#lookupGlobal_maybe"><span class="hs-identifier hs-type">lookupGlobal_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Maybe.html#MaybeErr"><span class="hs-identifier hs-type">MaybeErr</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-142"></span><span class="hs-comment">-- This may look up an Id that one has previously looked up.</span><span>
</span><span id="line-143"></span><span class="hs-comment">-- If so, we are going to read its interface file, and add its bindings</span><span>
</span><span id="line-144"></span><span class="hs-comment">-- to the ExternalPackageTable.</span><span>
</span><span id="line-145"></span><span id="lookupGlobal_maybe"><span class="annot"><span class="annottext">lookupGlobal_maybe :: HscEnv -&gt; Name -&gt; IO (MaybeErr MsgDoc TyThing)
</span><a href="GHC.Tc.Utils.Env.html#lookupGlobal_maybe"><span class="hs-identifier hs-var hs-var">lookupGlobal_maybe</span></a></span></span><span> </span><span id="local-6989586621681083695"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083695"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span> </span><span id="local-6989586621681083694"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083694"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-146"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span>    </span><span class="hs-comment">-- Try local envt</span><span>
</span><span id="line-147"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083693"><span class="annot"><span class="annottext">mod :: Module
</span><a href="#local-6989586621681083693"><span class="hs-identifier hs-var hs-var">mod</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InteractiveContext -&gt; Module
</span><a href="GHC.Driver.Types.html#icInteractiveModule"><span class="hs-identifier hs-var">icInteractiveModule</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HscEnv -&gt; InteractiveContext
</span><a href="GHC.Driver.Types.html#hsc_IC"><span class="hs-identifier hs-var hs-var">hsc_IC</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083695"><span class="hs-identifier hs-var">hsc_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>              </span><span id="local-6989586621681083690"><span class="annot"><span class="annottext">dflags :: DynFlags
</span><a href="#local-6989586621681083690"><span class="hs-identifier hs-var hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; DynFlags
</span><a href="GHC.Driver.Types.html#hsc_dflags"><span class="hs-identifier hs-var hs-var">hsc_dflags</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083695"><span class="hs-identifier hs-var">hsc_env</span></a></span><span>
</span><span id="line-149"></span><span>              </span><span id="local-6989586621681083688"><span class="annot"><span class="annottext">tcg_semantic_mod :: Module
</span><a href="#local-6989586621681083688"><span class="hs-identifier hs-var hs-var">tcg_semantic_mod</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Module -&gt; Module
</span><a href="GHC.Driver.Session.html#canonicalizeModuleIfHome"><span class="hs-identifier hs-var">canonicalizeModuleIfHome</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681083690"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083693"><span class="hs-identifier hs-var">mod</span></a></span><span>
</span><span id="line-150"></span><span>
</span><span id="line-151"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Module -&gt; Name -&gt; Bool
</span><a href="GHC.Types.Name.html#nameIsLocalOrFrom"><span class="hs-identifier hs-var">nameIsLocalOrFrom</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083688"><span class="hs-identifier hs-var">tcg_semantic_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083694"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-152"></span><span>              </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MaybeErr MsgDoc TyThing -&gt; IO (MaybeErr MsgDoc TyThing)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>
</span><span id="line-153"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MaybeErr MsgDoc TyThing
forall err val. err -&gt; MaybeErr err val
</span><a href="GHC.Data.Maybe.html#Failed"><span class="hs-identifier hs-var">Failed</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Can't find local name: &quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083694"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-154"></span><span>                  </span><span class="hs-comment">-- Internal names can happen in GHCi</span><span>
</span><span id="line-155"></span><span>              </span><span class="hs-keyword">else</span><span>
</span><span id="line-156"></span><span>           </span><span class="hs-comment">-- Try home package table and external package table</span><span>
</span><span id="line-157"></span><span>          </span><span class="annot"><span class="annottext">HscEnv -&gt; Name -&gt; IO (MaybeErr MsgDoc TyThing)
</span><a href="GHC.Tc.Utils.Env.html#lookupImported_maybe"><span class="hs-identifier hs-var">lookupImported_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083695"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083694"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-158"></span><span>        </span><span class="hs-special">}</span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#lookupImported_maybe"><span class="hs-identifier hs-type">lookupImported_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Maybe.html#MaybeErr"><span class="hs-identifier hs-type">MaybeErr</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-161"></span><span class="hs-comment">-- Returns (Failed err) if we can't find the interface file for the thing</span><span>
</span><span id="line-162"></span><span id="lookupImported_maybe"><span class="annot"><span class="annottext">lookupImported_maybe :: HscEnv -&gt; Name -&gt; IO (MaybeErr MsgDoc TyThing)
</span><a href="GHC.Tc.Utils.Env.html#lookupImported_maybe"><span class="hs-identifier hs-var hs-var">lookupImported_maybe</span></a></span></span><span> </span><span id="local-6989586621681083681"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083681"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span> </span><span id="local-6989586621681083680"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083680"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-163"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083679"><span class="annot"><span class="annottext">Maybe TyThing
</span><a href="#local-6989586621681083679"><span class="hs-identifier hs-var">mb_thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; Name -&gt; IO (Maybe TyThing)
</span><a href="GHC.Driver.Types.html#lookupTypeHscEnv"><span class="hs-identifier hs-var">lookupTypeHscEnv</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083681"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083680"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-164"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe TyThing
</span><a href="#local-6989586621681083679"><span class="hs-identifier hs-var">mb_thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-165"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681083677"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083677"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MaybeErr MsgDoc TyThing -&gt; IO (MaybeErr MsgDoc TyThing)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; MaybeErr MsgDoc TyThing
forall err val. val -&gt; MaybeErr err val
</span><a href="GHC.Data.Maybe.html#Succeeded"><span class="hs-identifier hs-var">Succeeded</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083677"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-166"></span><span>            </span><span class="annot"><span class="annottext">Maybe TyThing
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; Name -&gt; IO (MaybeErr MsgDoc TyThing)
</span><a href="GHC.Tc.Utils.Env.html#importDecl_maybe"><span class="hs-identifier hs-var">importDecl_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083681"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083680"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-167"></span><span>            </span><span class="hs-special">}</span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#importDecl_maybe"><span class="hs-identifier hs-type">importDecl_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Maybe.html#MaybeErr"><span class="hs-identifier hs-type">MaybeErr</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span id="importDecl_maybe"><span class="annot"><span class="annottext">importDecl_maybe :: HscEnv -&gt; Name -&gt; IO (MaybeErr MsgDoc TyThing)
</span><a href="GHC.Tc.Utils.Env.html#importDecl_maybe"><span class="hs-identifier hs-var hs-var">importDecl_maybe</span></a></span></span><span> </span><span id="local-6989586621681083675"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083675"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span> </span><span id="local-6989586621681083674"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083674"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-171"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681083673"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083673"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Maybe TyThing
</span><a href="GHC.Types.Name.html#wiredInNameTyThing_maybe"><span class="hs-identifier hs-var">wiredInNameTyThing_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083674"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-172"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; Bool
</span><a href="GHC.Iface.Load.html#needWiredInHomeIface"><span class="hs-identifier hs-var">needWiredInHomeIface</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083673"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-173"></span><span>               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HscEnv -&gt; IfG () -&gt; IO ()
forall a. HscEnv -&gt; IfG a -&gt; IO a
</span><a href="GHC.Tc.Utils.Monad.html#initIfaceLoad"><span class="hs-identifier hs-var">initIfaceLoad</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083675"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; IfG ()
forall lcl. Name -&gt; IfM lcl ()
</span><a href="GHC.Iface.Load.html#loadWiredInHomeIface"><span class="hs-identifier hs-var">loadWiredInHomeIface</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083674"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span>                </span><span class="hs-comment">-- See Note [Loading instances for wired-in things]</span><span>
</span><span id="line-175"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">MaybeErr MsgDoc TyThing -&gt; IO (MaybeErr MsgDoc TyThing)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; MaybeErr MsgDoc TyThing
forall err val. val -&gt; MaybeErr err val
</span><a href="GHC.Data.Maybe.html#Succeeded"><span class="hs-identifier hs-var">Succeeded</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083673"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-176"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-177"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HscEnv
-&gt; IfG (MaybeErr MsgDoc TyThing) -&gt; IO (MaybeErr MsgDoc TyThing)
forall a. HscEnv -&gt; IfG a -&gt; IO a
</span><a href="GHC.Tc.Utils.Monad.html#initIfaceLoad"><span class="hs-identifier hs-var">initIfaceLoad</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083675"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; IfG (MaybeErr MsgDoc TyThing)
forall lcl. Name -&gt; IfM lcl (MaybeErr MsgDoc TyThing)
</span><a href="GHC.Iface.Load.html#importDecl"><span class="hs-identifier hs-var">importDecl</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083674"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-178"></span><span>
</span><span id="line-179"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#ioLookupDataCon"><span class="hs-identifier hs-type">ioLookupDataCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span>
</span><span id="line-180"></span><span id="ioLookupDataCon"><span class="annot"><span class="annottext">ioLookupDataCon :: HscEnv -&gt; Name -&gt; IO DataCon
</span><a href="GHC.Tc.Utils.Env.html#ioLookupDataCon"><span class="hs-identifier hs-var hs-var">ioLookupDataCon</span></a></span></span><span> </span><span id="local-6989586621681083666"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083666"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span> </span><span id="local-6989586621681083665"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083665"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-181"></span><span>  </span><span id="local-6989586621681083664"><span class="annot"><span class="annottext">MaybeErr MsgDoc DataCon
</span><a href="#local-6989586621681083664"><span class="hs-identifier hs-var">mb_thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; Name -&gt; IO (MaybeErr MsgDoc DataCon)
</span><a href="GHC.Tc.Utils.Env.html#ioLookupDataCon_maybe"><span class="hs-identifier hs-var">ioLookupDataCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083666"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083665"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-182"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MaybeErr MsgDoc DataCon
</span><a href="#local-6989586621681083664"><span class="hs-identifier hs-var">mb_thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-183"></span><span>    </span><span class="annot"><a href="GHC.Data.Maybe.html#Succeeded"><span class="hs-identifier hs-type">Succeeded</span></a></span><span> </span><span id="local-6989586621681083662"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681083662"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; IO DataCon
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681083662"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-184"></span><span>    </span><span class="annot"><a href="GHC.Data.Maybe.html#Failed"><span class="hs-identifier hs-type">Failed</span></a></span><span> </span><span id="local-6989586621681083661"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083661"><span class="hs-identifier hs-var">msg</span></a></span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IO DataCon
forall a. HasCallStack =&gt; String -&gt; MsgDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookupDataConIO&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083661"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#ioLookupDataCon_maybe"><span class="hs-identifier hs-type">ioLookupDataCon_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Maybe.html#MaybeErr"><span class="hs-identifier hs-type">MaybeErr</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-187"></span><span id="ioLookupDataCon_maybe"><span class="annot"><span class="annottext">ioLookupDataCon_maybe :: HscEnv -&gt; Name -&gt; IO (MaybeErr MsgDoc DataCon)
</span><a href="GHC.Tc.Utils.Env.html#ioLookupDataCon_maybe"><span class="hs-identifier hs-var hs-var">ioLookupDataCon_maybe</span></a></span></span><span> </span><span id="local-6989586621681083660"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083660"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span> </span><span id="local-6989586621681083659"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083659"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-188"></span><span>    </span><span id="local-6989586621681083658"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083658"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; Name -&gt; IO TyThing
</span><a href="GHC.Tc.Utils.Env.html#lookupGlobal"><span class="hs-identifier hs-var">lookupGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681083660"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083659"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-189"></span><span>    </span><span class="annot"><span class="annottext">MaybeErr MsgDoc DataCon -&gt; IO (MaybeErr MsgDoc DataCon)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(MaybeErr MsgDoc DataCon -&gt; IO (MaybeErr MsgDoc DataCon))
-&gt; MaybeErr MsgDoc DataCon -&gt; IO (MaybeErr MsgDoc DataCon)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083658"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-190"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AConLike"><span class="hs-identifier hs-type">AConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-type">RealDataCon</span></a></span><span> </span><span id="local-6989586621681083655"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681083655"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; MaybeErr MsgDoc DataCon
forall err val. val -&gt; MaybeErr err val
</span><a href="GHC.Data.Maybe.html#Succeeded"><span class="hs-identifier hs-var">Succeeded</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681083655"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-191"></span><span>        </span><span class="annot"><span class="annottext">TyThing
</span><span class="hs-identifier">_</span></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MaybeErr MsgDoc DataCon
forall err val. err -&gt; MaybeErr err val
</span><a href="GHC.Data.Maybe.html#Failed"><span class="hs-identifier hs-var">Failed</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; MaybeErr MsgDoc DataCon)
-&gt; MsgDoc -&gt; MaybeErr MsgDoc DataCon
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-192"></span><span>          </span><span class="annot"><span class="annottext">TcTyThing -&gt; MsgDoc
</span><a href="GHC.Tc.Types.html#pprTcTyThingCategory"><span class="hs-identifier hs-var">pprTcTyThingCategory</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-var">AGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083658"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083659"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-193"></span><span>                </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;used as a data constructor&quot;</span></span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#addTypecheckedBinds"><span class="hs-identifier hs-type">addTypecheckedBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span>
</span><span id="line-196"></span><span id="addTypecheckedBinds"><span class="annot"><span class="annottext">addTypecheckedBinds :: TcGblEnv -&gt; [LHsBinds GhcTc] -&gt; TcGblEnv
</span><a href="GHC.Tc.Utils.Env.html#addTypecheckedBinds"><span class="hs-identifier hs-var hs-var">addTypecheckedBinds</span></a></span></span><span> </span><span id="local-6989586621681083651"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083651"><span class="hs-identifier hs-var">tcg_env</span></a></span></span><span> </span><span id="local-6989586621681083650"><span class="annot"><span class="annottext">[LHsBinds GhcTc]
</span><a href="#local-6989586621681083650"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-197"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">HscSource -&gt; Bool
</span><a href="GHC.Driver.Phases.html#isHsBootOrSig"><span class="hs-identifier hs-var">isHsBootOrSig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; HscSource
</span><a href="GHC.Tc.Types.html#tcg_src"><span class="hs-identifier hs-var hs-var">tcg_src</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083651"><span class="hs-identifier hs-var">tcg_env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083651"><span class="hs-identifier hs-var">tcg_env</span></a></span><span>
</span><span id="line-198"></span><span>    </span><span class="hs-comment">-- Do not add the code for record-selector bindings</span><span>
</span><span id="line-199"></span><span>    </span><span class="hs-comment">-- when compiling hs-boot files</span><span>
</span><span id="line-200"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083651"><span class="hs-identifier hs-var">tcg_env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_binds :: LHsBinds GhcTc
</span><a href="GHC.Tc.Types.html#tcg_binds"><span class="hs-identifier hs-var">tcg_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LHsBinds GhcTc -&gt; LHsBinds GhcTc -&gt; LHsBinds GhcTc)
-&gt; LHsBinds GhcTc -&gt; [LHsBinds GhcTc] -&gt; LHsBinds GhcTc
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; LHsBinds GhcTc -&gt; LHsBinds GhcTc
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-identifier hs-var">unionBags</span></a></span><span>
</span><span id="line-201"></span><span>                                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; LHsBinds GhcTc
</span><a href="GHC.Tc.Types.html#tcg_binds"><span class="hs-identifier hs-var hs-var">tcg_binds</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083651"><span class="hs-identifier hs-var">tcg_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-202"></span><span>                                            </span><span class="annot"><span class="annottext">[LHsBinds GhcTc]
</span><a href="#local-6989586621681083650"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-203"></span><span>
</span><span id="line-204"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
*                      tcLookupGlobal                                  *
*                                                                      *
************************************************************************

Using the Located versions (eg. tcLookupLocatedGlobal) is preferred,
unless you know that the SrcSpan in the monad is already set to the
span of the Name.
-}</span><span>
</span><span id="line-215"></span><span>
</span><span id="line-216"></span><span>
</span><span id="line-217"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedGlobal"><span class="hs-identifier hs-type">tcLookupLocatedGlobal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span>
</span><span id="line-218"></span><span class="hs-comment">-- c.f. GHC.IfaceToCore.tcIfaceGlobal</span><span>
</span><span id="line-219"></span><span id="tcLookupLocatedGlobal"><span class="annot"><span class="annottext">tcLookupLocatedGlobal :: Located Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedGlobal"><span class="hs-identifier hs-var hs-var">tcLookupLocatedGlobal</span></a></span></span><span> </span><span id="local-6989586621681083644"><span class="annot"><span class="annottext">Located Name
</span><a href="#local-6989586621681083644"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-220"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; TcM TyThing) -&gt; Located Name -&gt; TcM TyThing
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM b
</span><a href="GHC.Tc.Utils.Monad.html#addLocM"><span class="hs-identifier hs-var">addLocM</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var">tcLookupGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">Located Name
</span><a href="#local-6989586621681083644"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-type">tcLookupGlobal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span>
</span><span id="line-223"></span><span class="hs-comment">-- The Name is almost always an ExternalName, but not always</span><span>
</span><span id="line-224"></span><span class="hs-comment">-- In GHCi, we may make command-line bindings (ghci&gt; let x = True)</span><span>
</span><span id="line-225"></span><span class="hs-comment">-- that bind a GlobalId, but with an InternalName</span><span>
</span><span id="line-226"></span><span id="tcLookupGlobal"><span class="annot"><span class="annottext">tcLookupGlobal :: Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var hs-var">tcLookupGlobal</span></a></span></span><span> </span><span id="local-6989586621681083642"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083642"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-227"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span>    </span><span class="hs-comment">-- Try local envt</span><span>
</span><span id="line-228"></span><span>          </span><span id="local-6989586621681083641"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083641"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-229"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">NameEnv TyThing -&gt; Name -&gt; Maybe TyThing
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; NameEnv TyThing
</span><a href="GHC.Tc.Types.html#tcg_type_env"><span class="hs-identifier hs-var hs-var">tcg_type_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083641"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083642"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-230"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681083637"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083637"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyThing -&gt; TcM TyThing
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083637"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-special">;</span><span>
</span><span id="line-231"></span><span>                </span><span class="annot"><span class="annottext">Maybe TyThing
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-232"></span><span>
</span><span id="line-233"></span><span>                </span><span class="hs-comment">-- Should it have been in the local envt?</span><span>
</span><span id="line-234"></span><span>                </span><span class="hs-comment">-- (NB: use semantic mod here, since names never use</span><span>
</span><span id="line-235"></span><span>                </span><span class="hs-comment">-- identity module, see Note [Identity versus semantic module].)</span><span>
</span><span id="line-236"></span><span>          </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Module -&gt; Name -&gt; Bool
</span><a href="GHC.Types.Name.html#nameIsLocalOrFrom"><span class="hs-identifier hs-var">nameIsLocalOrFrom</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; Module
</span><a href="GHC.Tc.Types.html#tcg_semantic_mod"><span class="hs-identifier hs-var hs-var">tcg_semantic_mod</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083641"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083642"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-237"></span><span>          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#notFound"><span class="hs-identifier hs-var">notFound</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083642"><span class="hs-identifier hs-var">name</span></a></span><span>  </span><span class="hs-comment">-- Internal names can happen in GHCi</span><span>
</span><span id="line-238"></span><span>          </span><span class="hs-keyword">else</span><span>
</span><span id="line-239"></span><span>
</span><span id="line-240"></span><span>           </span><span class="hs-comment">-- Try home package table and external package table</span><span>
</span><span id="line-241"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083634"><span class="annot"><span class="annottext">MaybeErr MsgDoc TyThing
</span><a href="#local-6989586621681083634"><span class="hs-identifier hs-var">mb_thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM (MaybeErr MsgDoc TyThing)
</span><a href="GHC.Iface.Load.html#tcLookupImported_maybe"><span class="hs-identifier hs-var">tcLookupImported_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083642"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-242"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MaybeErr MsgDoc TyThing
</span><a href="#local-6989586621681083634"><span class="hs-identifier hs-var">mb_thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-243"></span><span>            </span><span class="annot"><a href="GHC.Data.Maybe.html#Succeeded"><span class="hs-identifier hs-type">Succeeded</span></a></span><span> </span><span id="local-6989586621681083632"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083632"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyThing -&gt; TcM TyThing
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083632"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-244"></span><span>            </span><span class="annot"><a href="GHC.Data.Maybe.html#Failed"><span class="hs-identifier hs-type">Failed</span></a></span><span> </span><span id="local-6989586621681083631"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083631"><span class="hs-identifier hs-var">msg</span></a></span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM TyThing
forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#failWithTc"><span class="hs-identifier hs-var">failWithTc</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083631"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-245"></span><span>        </span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">}</span><span>
</span><span id="line-246"></span><span>
</span><span id="line-247"></span><span class="hs-comment">-- Look up only in this module's global env't. Don't look in imports, etc.</span><span>
</span><span id="line-248"></span><span class="hs-comment">-- Panic if it's not there.</span><span>
</span><span id="line-249"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupGlobalOnly"><span class="hs-identifier hs-type">tcLookupGlobalOnly</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span>
</span><span id="line-250"></span><span id="tcLookupGlobalOnly"><span class="annot"><span class="annottext">tcLookupGlobalOnly :: Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobalOnly"><span class="hs-identifier hs-var hs-var">tcLookupGlobalOnly</span></a></span></span><span> </span><span id="local-6989586621681083629"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083629"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-251"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083628"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083628"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-252"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyThing -&gt; TcM TyThing
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TyThing -&gt; TcM TyThing) -&gt; TyThing -&gt; TcM TyThing
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">NameEnv TyThing -&gt; Name -&gt; Maybe TyThing
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; NameEnv TyThing
</span><a href="GHC.Tc.Types.html#tcg_type_env"><span class="hs-identifier hs-var hs-var">tcg_type_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083628"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083629"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-253"></span><span>                    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681083627"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083627"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083627"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-254"></span><span>                    </span><span class="annot"><span class="annottext">Maybe TyThing
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; TyThing
forall a. HasCallStack =&gt; String -&gt; MsgDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcLookupGlobalOnly&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083629"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-255"></span><span>
</span><span id="line-256"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupDataCon"><span class="hs-identifier hs-type">tcLookupDataCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span>
</span><span id="line-257"></span><span id="tcLookupDataCon"><span class="annot"><span class="annottext">tcLookupDataCon :: Name -&gt; TcM DataCon
</span><a href="GHC.Tc.Utils.Env.html#tcLookupDataCon"><span class="hs-identifier hs-var hs-var">tcLookupDataCon</span></a></span></span><span> </span><span id="local-6989586621681083626"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083626"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-258"></span><span>    </span><span id="local-6989586621681083625"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083625"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var">tcLookupGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083626"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-259"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083625"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-260"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AConLike"><span class="hs-identifier hs-type">AConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-type">RealDataCon</span></a></span><span> </span><span id="local-6989586621681083624"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681083624"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; TcM DataCon
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681083624"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-261"></span><span>        </span><span class="annot"><span class="annottext">TyThing
</span><span class="hs-identifier">_</span></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcTyThing -&gt; Name -&gt; TcM DataCon
forall a. String -&gt; TcTyThing -&gt; Name -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#wrongThingErr"><span class="hs-identifier hs-var">wrongThingErr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;data constructor&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-var">AGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083625"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083626"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-262"></span><span>
</span><span id="line-263"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupPatSyn"><span class="hs-identifier hs-type">tcLookupPatSyn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.PatSyn.html#PatSyn"><span class="hs-identifier hs-type">PatSyn</span></a></span><span>
</span><span id="line-264"></span><span id="tcLookupPatSyn"><span class="annot"><span class="annottext">tcLookupPatSyn :: Name -&gt; TcM PatSyn
</span><a href="GHC.Tc.Utils.Env.html#tcLookupPatSyn"><span class="hs-identifier hs-var hs-var">tcLookupPatSyn</span></a></span></span><span> </span><span id="local-6989586621681083623"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083623"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-265"></span><span>    </span><span id="local-6989586621681083622"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083622"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var">tcLookupGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083623"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-266"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083622"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-267"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AConLike"><span class="hs-identifier hs-type">AConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#PatSynCon"><span class="hs-identifier hs-type">PatSynCon</span></a></span><span> </span><span id="local-6989586621681083620"><span class="annot"><span class="annottext">PatSyn
</span><a href="#local-6989586621681083620"><span class="hs-identifier hs-var">ps</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PatSyn -&gt; TcM PatSyn
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">PatSyn
</span><a href="#local-6989586621681083620"><span class="hs-identifier hs-var">ps</span></a></span><span>
</span><span id="line-268"></span><span>        </span><span class="annot"><span class="annottext">TyThing
</span><span class="hs-identifier">_</span></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcTyThing -&gt; Name -&gt; TcM PatSyn
forall a. String -&gt; TcTyThing -&gt; Name -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#wrongThingErr"><span class="hs-identifier hs-var">wrongThingErr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;pattern synonym&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-var">AGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083622"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083623"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-269"></span><span>
</span><span id="line-270"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupConLike"><span class="hs-identifier hs-type">tcLookupConLike</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html#ConLike"><span class="hs-identifier hs-type">ConLike</span></a></span><span>
</span><span id="line-271"></span><span id="tcLookupConLike"><span class="annot"><span class="annottext">tcLookupConLike :: Name -&gt; TcM ConLike
</span><a href="GHC.Tc.Utils.Env.html#tcLookupConLike"><span class="hs-identifier hs-var hs-var">tcLookupConLike</span></a></span></span><span> </span><span id="local-6989586621681083619"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083619"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-272"></span><span>    </span><span id="local-6989586621681083618"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083618"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var">tcLookupGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083619"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-273"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083618"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-274"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AConLike"><span class="hs-identifier hs-type">AConLike</span></a></span><span> </span><span id="local-6989586621681083617"><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681083617"><span class="hs-identifier hs-var">cl</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ConLike -&gt; TcM ConLike
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ConLike
</span><a href="#local-6989586621681083617"><span class="hs-identifier hs-var">cl</span></a></span><span>
</span><span id="line-275"></span><span>        </span><span class="annot"><span class="annottext">TyThing
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcTyThing -&gt; Name -&gt; TcM ConLike
forall a. String -&gt; TcTyThing -&gt; Name -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#wrongThingErr"><span class="hs-identifier hs-var">wrongThingErr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;constructor-like thing&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-var">AGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083618"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083619"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-276"></span><span>
</span><span id="line-277"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupClass"><span class="hs-identifier hs-type">tcLookupClass</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span>
</span><span id="line-278"></span><span id="tcLookupClass"><span class="annot"><span class="annottext">tcLookupClass :: Name -&gt; TcM Class
</span><a href="GHC.Tc.Utils.Env.html#tcLookupClass"><span class="hs-identifier hs-var hs-var">tcLookupClass</span></a></span></span><span> </span><span id="local-6989586621681083616"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083616"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-279"></span><span>    </span><span id="local-6989586621681083615"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083615"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var">tcLookupGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083616"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-280"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083615"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-281"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ATyCon"><span class="hs-identifier hs-type">ATyCon</span></a></span><span> </span><span id="local-6989586621681083613"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083613"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681083612"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681083612"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe Class
</span><a href="GHC.Core.TyCon.html#tyConClass_maybe"><span class="hs-identifier hs-var">tyConClass_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083613"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Class -&gt; TcM Class
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681083612"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-282"></span><span>        </span><span class="annot"><span class="annottext">TyThing
</span><span class="hs-identifier">_</span></span><span>                                           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcTyThing -&gt; Name -&gt; TcM Class
forall a. String -&gt; TcTyThing -&gt; Name -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#wrongThingErr"><span class="hs-identifier hs-var">wrongThingErr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;class&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-var">AGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083615"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083616"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-283"></span><span>
</span><span id="line-284"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupTyCon"><span class="hs-identifier hs-type">tcLookupTyCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-285"></span><span id="tcLookupTyCon"><span class="annot"><span class="annottext">tcLookupTyCon :: Name -&gt; TcM TyCon
</span><a href="GHC.Tc.Utils.Env.html#tcLookupTyCon"><span class="hs-identifier hs-var hs-var">tcLookupTyCon</span></a></span></span><span> </span><span id="local-6989586621681083610"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083610"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-286"></span><span>    </span><span id="local-6989586621681083609"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083609"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var">tcLookupGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083610"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-287"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083609"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-288"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ATyCon"><span class="hs-identifier hs-type">ATyCon</span></a></span><span> </span><span id="local-6989586621681083608"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083608"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TcM TyCon
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083608"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-289"></span><span>        </span><span class="annot"><span class="annottext">TyThing
</span><span class="hs-identifier">_</span></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcTyThing -&gt; Name -&gt; TcM TyCon
forall a. String -&gt; TcTyThing -&gt; Name -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#wrongThingErr"><span class="hs-identifier hs-var">wrongThingErr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;type constructor&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-var">AGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083609"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083610"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-290"></span><span>
</span><span id="line-291"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupAxiom"><span class="hs-identifier hs-type">tcLookupAxiom</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#CoAxiom"><span class="hs-identifier hs-type">CoAxiom</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Branched"><span class="hs-identifier hs-type">Branched</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-292"></span><span id="tcLookupAxiom"><span class="annot"><span class="annottext">tcLookupAxiom :: Name -&gt; TcM (CoAxiom Branched)
</span><a href="GHC.Tc.Utils.Env.html#tcLookupAxiom"><span class="hs-identifier hs-var hs-var">tcLookupAxiom</span></a></span></span><span> </span><span id="local-6989586621681083607"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083607"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-293"></span><span>    </span><span id="local-6989586621681083606"><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083606"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var">tcLookupGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083607"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-294"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083606"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-295"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ACoAxiom"><span class="hs-identifier hs-type">ACoAxiom</span></a></span><span> </span><span id="local-6989586621681083604"><span class="annot"><span class="annottext">CoAxiom Branched
</span><a href="#local-6989586621681083604"><span class="hs-identifier hs-var">ax</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoAxiom Branched -&gt; TcM (CoAxiom Branched)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiom Branched
</span><a href="#local-6989586621681083604"><span class="hs-identifier hs-var">ax</span></a></span><span>
</span><span id="line-296"></span><span>        </span><span class="annot"><span class="annottext">TyThing
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcTyThing -&gt; Name -&gt; TcM (CoAxiom Branched)
forall a. String -&gt; TcTyThing -&gt; Name -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#wrongThingErr"><span class="hs-identifier hs-var">wrongThingErr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;axiom&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-var">AGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">TyThing
</span><a href="#local-6989586621681083606"><span class="hs-identifier hs-var">thing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083607"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-297"></span><span>
</span><span id="line-298"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedGlobalId"><span class="hs-identifier hs-type">tcLookupLocatedGlobalId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-299"></span><span id="tcLookupLocatedGlobalId"><span class="annot"><span class="annottext">tcLookupLocatedGlobalId :: Located Name -&gt; TcM Id
</span><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedGlobalId"><span class="hs-identifier hs-var hs-var">tcLookupLocatedGlobalId</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; TcM Id) -&gt; Located Name -&gt; TcM Id
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM b
</span><a href="GHC.Tc.Utils.Monad.html#addLocM"><span class="hs-identifier hs-var">addLocM</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM Id
</span><a href="GHC.Tc.Utils.Env.html#tcLookupId"><span class="hs-identifier hs-var">tcLookupId</span></a></span><span>
</span><span id="line-300"></span><span>
</span><span id="line-301"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedClass"><span class="hs-identifier hs-type">tcLookupLocatedClass</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span>
</span><span id="line-302"></span><span id="tcLookupLocatedClass"><span class="annot"><span class="annottext">tcLookupLocatedClass :: Located Name -&gt; TcM Class
</span><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedClass"><span class="hs-identifier hs-var hs-var">tcLookupLocatedClass</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; TcM Class) -&gt; Located Name -&gt; TcM Class
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM b
</span><a href="GHC.Tc.Utils.Monad.html#addLocM"><span class="hs-identifier hs-var">addLocM</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM Class
</span><a href="GHC.Tc.Utils.Env.html#tcLookupClass"><span class="hs-identifier hs-var">tcLookupClass</span></a></span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedTyCon"><span class="hs-identifier hs-type">tcLookupLocatedTyCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-305"></span><span id="tcLookupLocatedTyCon"><span class="annot"><span class="annottext">tcLookupLocatedTyCon :: Located Name -&gt; TcM TyCon
</span><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedTyCon"><span class="hs-identifier hs-var hs-var">tcLookupLocatedTyCon</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; TcM TyCon) -&gt; Located Name -&gt; TcM TyCon
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM b
</span><a href="GHC.Tc.Utils.Monad.html#addLocM"><span class="hs-identifier hs-var">addLocM</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyCon
</span><a href="GHC.Tc.Utils.Env.html#tcLookupTyCon"><span class="hs-identifier hs-var">tcLookupTyCon</span></a></span><span>
</span><span id="line-306"></span><span>
</span><span id="line-307"></span><span class="hs-comment">-- Find the instance that exactly matches a type class application.  The class arguments must be precisely</span><span>
</span><span id="line-308"></span><span class="hs-comment">-- the same as in the instance declaration (modulo renaming &amp; casts).</span><span>
</span><span id="line-309"></span><span class="hs-comment">--</span><span>
</span><span id="line-310"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupInstance"><span class="hs-identifier hs-type">tcLookupInstance</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span>
</span><span id="line-311"></span><span id="tcLookupInstance"><span class="annot"><span class="annottext">tcLookupInstance :: Class -&gt; [Type] -&gt; TcM ClsInst
</span><a href="GHC.Tc.Utils.Env.html#tcLookupInstance"><span class="hs-identifier hs-var hs-var">tcLookupInstance</span></a></span></span><span> </span><span id="local-6989586621681083603"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681083603"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681083602"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083602"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-312"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083601"><span class="annot"><span class="annottext">InstEnvs
</span><a href="#local-6989586621681083601"><span class="hs-identifier hs-var">instEnv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM InstEnvs
</span><a href="GHC.Tc.Utils.Env.html#tcGetInstEnvs"><span class="hs-identifier hs-var">tcGetInstEnvs</span></a></span><span>
</span><span id="line-313"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">InstEnvs -&gt; Class -&gt; [Type] -&gt; Either MsgDoc (ClsInst, [Type])
</span><a href="GHC.Core.InstEnv.html#lookupUniqueInstEnv"><span class="hs-identifier hs-var">lookupUniqueInstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">InstEnvs
</span><a href="#local-6989586621681083601"><span class="hs-identifier hs-var">instEnv</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681083603"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083602"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-314"></span><span>           </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621681083599"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083599"><span class="hs-identifier hs-var">err</span></a></span></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ClsInst
forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#failWithTc"><span class="hs-identifier hs-var">failWithTc</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; TcM ClsInst) -&gt; MsgDoc -&gt; TcM ClsInst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Couldn't match instance:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083599"><span class="hs-identifier hs-var">err</span></a></span><span>
</span><span id="line-315"></span><span>           </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083598"><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681083598"><span class="hs-identifier hs-var">inst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681083597"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083597"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-316"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; Bool
</span><a href="#local-6989586621681083596"><span class="hs-identifier hs-var">uniqueTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083597"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; TcM ClsInst
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681083598"><span class="hs-identifier hs-var">inst</span></a></span><span>
</span><span id="line-317"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ClsInst
forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#failWithTc"><span class="hs-identifier hs-var">failWithTc</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083595"><span class="hs-identifier hs-var">errNotExact</span></a></span><span>
</span><span id="line-318"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-319"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-320"></span><span>    </span><span id="local-6989586621681083595"><span class="annot"><span class="annottext">errNotExact :: MsgDoc
</span><a href="#local-6989586621681083595"><span class="hs-identifier hs-var hs-var">errNotExact</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Not an exact match (i.e., some variables get instantiated)&quot;</span></span><span>
</span><span id="line-321"></span><span>
</span><span id="line-322"></span><span>    </span><span id="local-6989586621681083596"><span class="annot"><span class="annottext">uniqueTyVars :: [Type] -&gt; Bool
</span><a href="#local-6989586621681083596"><span class="hs-identifier hs-var hs-var">uniqueTyVars</span></a></span></span><span> </span><span id="local-6989586621681083591"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083591"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; [Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isTyVarTy"><span class="hs-identifier hs-var">isTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083591"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-323"></span><span>                    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; Bool
</span><a href="GHC.Data.List.SetOps.html#hasNoDups"><span class="hs-identifier hs-var">hasNoDups</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; Id) -&gt; [Type] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Type -&gt; Id
</span><a href="GHC.Core.Type.html#getTyVar"><span class="hs-identifier hs-var">getTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcLookupInstance&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083591"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-324"></span><span>
</span><span id="line-325"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcGetInstEnvs"><span class="hs-identifier hs-type">tcGetInstEnvs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#InstEnvs"><span class="hs-identifier hs-type">InstEnvs</span></a></span><span>
</span><span id="line-326"></span><span class="hs-comment">-- Gets both the external-package inst-env</span><span>
</span><span id="line-327"></span><span class="hs-comment">-- and the home-pkg inst env (includes module being compiled)</span><span>
</span><span id="line-328"></span><span id="tcGetInstEnvs"><span class="annot"><span class="annottext">tcGetInstEnvs :: TcM InstEnvs
</span><a href="GHC.Tc.Utils.Env.html#tcGetInstEnvs"><span class="hs-identifier hs-var hs-var">tcGetInstEnvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083585"><span class="annot"><span class="annottext">ExternalPackageState
</span><a href="#local-6989586621681083585"><span class="hs-identifier hs-var">eps</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv ExternalPackageState
forall gbl lcl. TcRnIf gbl lcl ExternalPackageState
</span><a href="GHC.Tc.Utils.Monad.html#getEps"><span class="hs-identifier hs-var">getEps</span></a></span><span>
</span><span id="line-329"></span><span>                   </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083583"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083583"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-330"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">InstEnvs -&gt; TcM InstEnvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstEnvs :: InstEnv -&gt; InstEnv -&gt; VisibleOrphanModules -&gt; InstEnvs
</span><a href="GHC.Core.InstEnv.html#InstEnvs"><span class="hs-identifier hs-type">InstEnvs</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ie_global :: InstEnv
</span><a href="GHC.Core.InstEnv.html#ie_global"><span class="hs-identifier hs-var">ie_global</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ExternalPackageState -&gt; InstEnv
</span><a href="GHC.Driver.Types.html#eps_inst_env"><span class="hs-identifier hs-var hs-var">eps_inst_env</span></a></span><span> </span><span class="annot"><span class="annottext">ExternalPackageState
</span><a href="#local-6989586621681083585"><span class="hs-identifier hs-var">eps</span></a></span><span>
</span><span id="line-331"></span><span>                                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ie_local :: InstEnv
</span><a href="GHC.Core.InstEnv.html#ie_local"><span class="hs-identifier hs-var">ie_local</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; InstEnv
</span><a href="GHC.Tc.Types.html#tcg_inst_env"><span class="hs-identifier hs-var hs-var">tcg_inst_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083583"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-332"></span><span>                                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ie_visible :: VisibleOrphanModules
</span><a href="GHC.Core.InstEnv.html#ie_visible"><span class="hs-identifier hs-var">ie_visible</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; VisibleOrphanModules
</span><a href="GHC.Tc.Types.html#tcVisibleOrphanMods"><span class="hs-identifier hs-var">tcVisibleOrphanMods</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083583"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-333"></span><span>
</span><span id="line-334"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681083567"><span id="local-6989586621681083569"><span id="local-6989586621681083571"><span class="annot"><a href="GHC.Driver.Types.html#MonadThings"><span class="hs-identifier hs-type">MonadThings</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.IOEnv.html#IOEnv"><span class="hs-identifier hs-type">IOEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#Env"><span class="hs-identifier hs-type">Env</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcLclEnv"><span class="hs-identifier hs-type">TcLclEnv</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-335"></span><span>    </span><span id="local-6989586621681083565"><span class="annot"><span class="annottext">lookupThing :: Name -&gt; TcM TyThing
</span><a href="GHC.Driver.Types.html#lookupThing"><span class="hs-identifier hs-var hs-var hs-var hs-var">lookupThing</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var">tcLookupGlobal</span></a></span><span>
</span><span id="line-336"></span><span>
</span><span id="line-337"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Extending the global environment
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-344"></span><span>
</span><span id="line-345"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#setGlobalTypeEnv"><span class="hs-identifier hs-type">setGlobalTypeEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#TypeEnv"><span class="hs-identifier hs-type">TypeEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span>
</span><span id="line-346"></span><span class="hs-comment">-- Use this to update the global type env</span><span>
</span><span id="line-347"></span><span class="hs-comment">-- It updates both  * the normal tcg_type_env field</span><span>
</span><span id="line-348"></span><span class="hs-comment">--                  * the tcg_type_env_var field seen by interface files</span><span>
</span><span id="line-349"></span><span id="setGlobalTypeEnv"><span class="annot"><span class="annottext">setGlobalTypeEnv :: TcGblEnv -&gt; NameEnv TyThing -&gt; TcRnIf TcGblEnv TcLclEnv TcGblEnv
</span><a href="GHC.Tc.Utils.Env.html#setGlobalTypeEnv"><span class="hs-identifier hs-var hs-var">setGlobalTypeEnv</span></a></span></span><span> </span><span id="local-6989586621681083562"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083562"><span class="hs-identifier hs-var">tcg_env</span></a></span></span><span> </span><span id="local-6989586621681083561"><span class="annot"><span class="annottext">NameEnv TyThing
</span><a href="#local-6989586621681083561"><span class="hs-identifier hs-var">new_type_env</span></a></span></span><span>
</span><span id="line-350"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span>     </span><span class="hs-comment">-- Sync the type-envt variable seen by interface files</span><span>
</span><span id="line-351"></span><span>           </span><span class="annot"><span class="annottext">IORef (NameEnv TyThing)
-&gt; NameEnv TyThing -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a env. IORef a -&gt; a -&gt; IOEnv env ()
</span><a href="GHC.Data.IOEnv.html#writeMutVar"><span class="hs-identifier hs-var">writeMutVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; IORef (NameEnv TyThing)
</span><a href="GHC.Tc.Types.html#tcg_type_env_var"><span class="hs-identifier hs-var hs-var">tcg_type_env_var</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083562"><span class="hs-identifier hs-var">tcg_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">NameEnv TyThing
</span><a href="#local-6989586621681083561"><span class="hs-identifier hs-var">new_type_env</span></a></span><span>
</span><span id="line-352"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083562"><span class="hs-identifier hs-var">tcg_env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_type_env :: NameEnv TyThing
</span><a href="GHC.Tc.Types.html#tcg_type_env"><span class="hs-identifier hs-var">tcg_type_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyThing
</span><a href="#local-6989586621681083561"><span class="hs-identifier hs-var">new_type_env</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-353"></span><span>
</span><span id="line-354"></span><span>
</span><span id="line-355"></span><span id="local-6989586621681084130"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnvImplicit"><span class="hs-identifier hs-type">tcExtendGlobalEnvImplicit</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084130"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084130"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-356"></span><span>  </span><span class="hs-comment">-- Just extend the global environment with some TyThings</span><span>
</span><span id="line-357"></span><span>  </span><span class="hs-comment">-- Do not extend tcg_tcs, tcg_patsyns etc</span><span>
</span><span id="line-358"></span><span id="tcExtendGlobalEnvImplicit"><span class="annot"><span class="annottext">tcExtendGlobalEnvImplicit :: forall r. [TyThing] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnvImplicit"><span class="hs-identifier hs-var hs-var">tcExtendGlobalEnvImplicit</span></a></span></span><span> </span><span id="local-6989586621681083556"><span class="annot"><span class="annottext">[TyThing]
</span><a href="#local-6989586621681083556"><span class="hs-identifier hs-var">things</span></a></span></span><span> </span><span id="local-6989586621681083555"><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083555"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-359"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083554"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083554"><span class="hs-identifier hs-var">tcg_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-360"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083553"><span class="annot"><span class="annottext">ge' :: NameEnv TyThing
</span><a href="#local-6989586621681083553"><span class="hs-identifier hs-var hs-var">ge'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyThing -&gt; [TyThing] -&gt; NameEnv TyThing
</span><a href="GHC.Driver.Types.html#extendTypeEnvList"><span class="hs-identifier hs-var">extendTypeEnvList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; NameEnv TyThing
</span><a href="GHC.Tc.Types.html#tcg_type_env"><span class="hs-identifier hs-var hs-var">tcg_type_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083554"><span class="hs-identifier hs-var">tcg_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TyThing]
</span><a href="#local-6989586621681083556"><span class="hs-identifier hs-var">things</span></a></span><span>
</span><span id="line-361"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083551"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083551"><span class="hs-identifier hs-var">tcg_env'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; NameEnv TyThing -&gt; TcRnIf TcGblEnv TcLclEnv TcGblEnv
</span><a href="GHC.Tc.Utils.Env.html#setGlobalTypeEnv"><span class="hs-identifier hs-var">setGlobalTypeEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083554"><span class="hs-identifier hs-var">tcg_env</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyThing
</span><a href="#local-6989586621681083553"><span class="hs-identifier hs-var">ge'</span></a></span><span>
</span><span id="line-362"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM r -&gt; TcM r
forall gbl lcl a. gbl -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setGblEnv"><span class="hs-identifier hs-var">setGblEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083551"><span class="hs-identifier hs-var">tcg_env'</span></a></span><span> </span><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083555"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-363"></span><span>
</span><span id="line-364"></span><span id="local-6989586621681083549"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnv"><span class="hs-identifier hs-type">tcExtendGlobalEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083549"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083549"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-365"></span><span>  </span><span class="hs-comment">-- Given a mixture of Ids, TyCons, Classes, all defined in the</span><span>
</span><span id="line-366"></span><span>  </span><span class="hs-comment">-- module being compiled, extend the global environment</span><span>
</span><span id="line-367"></span><span id="tcExtendGlobalEnv"><span class="annot"><span class="annottext">tcExtendGlobalEnv :: forall r. [TyThing] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnv"><span class="hs-identifier hs-var hs-var">tcExtendGlobalEnv</span></a></span></span><span> </span><span id="local-6989586621681083547"><span class="annot"><span class="annottext">[TyThing]
</span><a href="#local-6989586621681083547"><span class="hs-identifier hs-var">things</span></a></span></span><span> </span><span id="local-6989586621681083546"><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083546"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-368"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083545"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083545"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-369"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083544"><span class="annot"><span class="annottext">env' :: TcGblEnv
</span><a href="#local-6989586621681083544"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083545"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_tcs :: [TyCon]
</span><a href="GHC.Tc.Types.html#tcg_tcs"><span class="hs-identifier hs-var">tcg_tcs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083542"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ATyCon"><span class="hs-identifier hs-type">ATyCon</span></a></span><span> </span><span id="local-6989586621681083542"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083542"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TyThing]
</span><a href="#local-6989586621681083547"><span class="hs-identifier hs-var">things</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[TyCon] -&gt; [TyCon] -&gt; [TyCon]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; [TyCon]
</span><a href="GHC.Tc.Types.html#tcg_tcs"><span class="hs-identifier hs-var hs-var">tcg_tcs</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083545"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-370"></span><span>                          </span><span class="annot"><span class="annottext">tcg_patsyns :: [PatSyn]
</span><a href="GHC.Tc.Types.html#tcg_patsyns"><span class="hs-identifier hs-var">tcg_patsyns</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">PatSyn
</span><a href="#local-6989586621681083540"><span class="hs-identifier hs-var">ps</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AConLike"><span class="hs-identifier hs-type">AConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.ConLike.html#PatSynCon"><span class="hs-identifier hs-type">PatSynCon</span></a></span><span> </span><span id="local-6989586621681083540"><span class="annot"><span class="annottext">PatSyn
</span><a href="#local-6989586621681083540"><span class="hs-identifier hs-var">ps</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TyThing]
</span><a href="#local-6989586621681083547"><span class="hs-identifier hs-var">things</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[PatSyn] -&gt; [PatSyn] -&gt; [PatSyn]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; [PatSyn]
</span><a href="GHC.Tc.Types.html#tcg_patsyns"><span class="hs-identifier hs-var hs-var">tcg_patsyns</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083545"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-371"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM r -&gt; TcM r
forall gbl lcl a. gbl -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setGblEnv"><span class="hs-identifier hs-var">setGblEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083544"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM r -&gt; TcM r) -&gt; TcM r -&gt; TcM r
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-372"></span><span>            </span><span class="annot"><span class="annottext">[TyThing] -&gt; TcM r -&gt; TcM r
forall r. [TyThing] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnvImplicit"><span class="hs-identifier hs-var">tcExtendGlobalEnvImplicit</span></a></span><span> </span><span class="annot"><span class="annottext">[TyThing]
</span><a href="#local-6989586621681083547"><span class="hs-identifier hs-var">things</span></a></span><span> </span><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083546"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-373"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-374"></span><span>
</span><span id="line-375"></span><span id="local-6989586621681084123"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendTyConEnv"><span class="hs-identifier hs-type">tcExtendTyConEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084123"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084123"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-376"></span><span>  </span><span class="hs-comment">-- Given a mixture of Ids, TyCons, Classes, all defined in the</span><span>
</span><span id="line-377"></span><span>  </span><span class="hs-comment">-- module being compiled, extend the global environment</span><span>
</span><span id="line-378"></span><span id="tcExtendTyConEnv"><span class="annot"><span class="annottext">tcExtendTyConEnv :: forall r. [TyCon] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendTyConEnv"><span class="hs-identifier hs-var hs-var">tcExtendTyConEnv</span></a></span></span><span> </span><span id="local-6989586621681083538"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681083538"><span class="hs-identifier hs-var">tycons</span></a></span></span><span> </span><span id="local-6989586621681083537"><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083537"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-379"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083536"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083536"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-380"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083535"><span class="annot"><span class="annottext">env' :: TcGblEnv
</span><a href="#local-6989586621681083535"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083536"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_tcs :: [TyCon]
</span><a href="GHC.Tc.Types.html#tcg_tcs"><span class="hs-identifier hs-var">tcg_tcs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681083538"><span class="hs-identifier hs-var">tycons</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon] -&gt; [TyCon] -&gt; [TyCon]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; [TyCon]
</span><a href="GHC.Tc.Types.html#tcg_tcs"><span class="hs-identifier hs-var hs-var">tcg_tcs</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083536"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-381"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM r -&gt; TcM r
forall gbl lcl a. gbl -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setGblEnv"><span class="hs-identifier hs-var">setGblEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083535"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM r -&gt; TcM r) -&gt; TcM r -&gt; TcM r
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-382"></span><span>         </span><span class="annot"><span class="annottext">[TyThing] -&gt; TcM r -&gt; TcM r
forall r. [TyThing] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnvImplicit"><span class="hs-identifier hs-var">tcExtendGlobalEnvImplicit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TyCon -&gt; TyThing) -&gt; [TyCon] -&gt; [TyThing]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TyThing
</span><a href="GHC.Core.TyCo.Rep.html#ATyCon"><span class="hs-identifier hs-var">ATyCon</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681083538"><span class="hs-identifier hs-var">tycons</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083537"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-383"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-384"></span><span>
</span><span id="line-385"></span><span id="local-6989586621681084121"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalValEnv"><span class="hs-identifier hs-type">tcExtendGlobalValEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084121"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084121"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-386"></span><span>  </span><span class="hs-comment">-- Same deal as tcExtendGlobalEnv, but for Ids</span><span>
</span><span id="line-387"></span><span id="tcExtendGlobalValEnv"><span class="annot"><span class="annottext">tcExtendGlobalValEnv :: forall a. [Id] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalValEnv"><span class="hs-identifier hs-var hs-var">tcExtendGlobalValEnv</span></a></span></span><span> </span><span id="local-6989586621681083534"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083534"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621681083533"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083533"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-388"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyThing] -&gt; TcM a -&gt; TcM a
forall r. [TyThing] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnvImplicit"><span class="hs-identifier hs-var">tcExtendGlobalEnvImplicit</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id -&gt; TyThing
</span><a href="GHC.Core.TyCo.Rep.html#AnId"><span class="hs-identifier hs-var">AnId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083531"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681083531"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083531"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083534"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083533"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-389"></span><span>
</span><span id="line-390"></span><span id="local-6989586621681084119"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendRecEnv"><span class="hs-identifier hs-type">tcExtendRecEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084119"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084119"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-391"></span><span class="hs-comment">-- Extend the global environments for the type/class knot tying game</span><span>
</span><span id="line-392"></span><span class="hs-comment">-- Just like tcExtendGlobalEnv, except the argument is a list of pairs</span><span>
</span><span id="line-393"></span><span id="tcExtendRecEnv"><span class="annot"><span class="annottext">tcExtendRecEnv :: forall r. [(Name, TyThing)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendRecEnv"><span class="hs-identifier hs-var hs-var">tcExtendRecEnv</span></a></span></span><span> </span><span id="local-6989586621681083529"><span class="annot"><span class="annottext">[(Name, TyThing)]
</span><a href="#local-6989586621681083529"><span class="hs-identifier hs-var">gbl_stuff</span></a></span></span><span> </span><span id="local-6989586621681083528"><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083528"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-394"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083527"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083527"><span class="hs-identifier hs-var">tcg_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-395"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083526"><span class="annot"><span class="annottext">ge' :: NameEnv TyThing
</span><a href="#local-6989586621681083526"><span class="hs-identifier hs-var hs-var">ge'</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyThing -&gt; [(Name, TyThing)] -&gt; NameEnv TyThing
forall a. NameEnv a -&gt; [(Name, a)] -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#extendNameEnvList"><span class="hs-identifier hs-var">extendNameEnvList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; NameEnv TyThing
</span><a href="GHC.Tc.Types.html#tcg_type_env"><span class="hs-identifier hs-var hs-var">tcg_type_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083527"><span class="hs-identifier hs-var">tcg_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Name, TyThing)]
</span><a href="#local-6989586621681083529"><span class="hs-identifier hs-var">gbl_stuff</span></a></span><span>
</span><span id="line-396"></span><span>             </span><span id="local-6989586621681083524"><span class="annot"><span class="annottext">tcg_env' :: TcGblEnv
</span><a href="#local-6989586621681083524"><span class="hs-identifier hs-var hs-var">tcg_env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083527"><span class="hs-identifier hs-var">tcg_env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_type_env :: NameEnv TyThing
</span><a href="GHC.Tc.Types.html#tcg_type_env"><span class="hs-identifier hs-var">tcg_type_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv TyThing
</span><a href="#local-6989586621681083526"><span class="hs-identifier hs-var">ge'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-397"></span><span>         </span><span class="hs-comment">-- No need for setGlobalTypeEnv (which side-effects the</span><span>
</span><span id="line-398"></span><span>         </span><span class="hs-comment">-- tcg_type_env_var); tcExtendRecEnv is used just</span><span>
</span><span id="line-399"></span><span>         </span><span class="hs-comment">-- when kind-check a group of type/class decls. It would</span><span>
</span><span id="line-400"></span><span>         </span><span class="hs-comment">-- in any case be wrong for an interface-file decl to end up</span><span>
</span><span id="line-401"></span><span>         </span><span class="hs-comment">-- with a TcTyCon in it!</span><span>
</span><span id="line-402"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM r -&gt; TcM r
forall gbl lcl a. gbl -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setGblEnv"><span class="hs-identifier hs-var">setGblEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083524"><span class="hs-identifier hs-var">tcg_env'</span></a></span><span> </span><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083528"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-403"></span><span>
</span><span id="line-404"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{The local environment}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-411"></span><span>
</span><span id="line-412"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocated"><span class="hs-identifier hs-type">tcLookupLocated</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTyThing"><span class="hs-identifier hs-type">TcTyThing</span></a></span><span>
</span><span id="line-413"></span><span id="tcLookupLocated"><span class="annot"><span class="annottext">tcLookupLocated :: Located Name -&gt; TcM TcTyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupLocated"><span class="hs-identifier hs-var hs-var">tcLookupLocated</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; TcM TcTyThing) -&gt; Located Name -&gt; TcM TcTyThing
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM b
</span><a href="GHC.Tc.Utils.Monad.html#addLocM"><span class="hs-identifier hs-var">addLocM</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TcTyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookup"><span class="hs-identifier hs-var">tcLookup</span></a></span><span>
</span><span id="line-414"></span><span>
</span><span id="line-415"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLcl_maybe"><span class="hs-identifier hs-type">tcLookupLcl_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTyThing"><span class="hs-identifier hs-type">TcTyThing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-416"></span><span id="tcLookupLcl_maybe"><span class="annot"><span class="annottext">tcLookupLcl_maybe :: Name -&gt; TcM (Maybe TcTyThing)
</span><a href="GHC.Tc.Utils.Env.html#tcLookupLcl_maybe"><span class="hs-identifier hs-var hs-var">tcLookupLcl_maybe</span></a></span></span><span> </span><span id="local-6989586621681083523"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083523"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-417"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083522"><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083522"><span class="hs-identifier hs-var">local_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcTypeEnv
</span><a href="GHC.Tc.Utils.Monad.html#getLclTypeEnv"><span class="hs-identifier hs-var">getLclTypeEnv</span></a></span><span>
</span><span id="line-418"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe TcTyThing -&gt; TcM (Maybe TcTyThing)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTypeEnv -&gt; Name -&gt; Maybe TcTyThing
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083522"><span class="hs-identifier hs-var">local_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083523"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-419"></span><span>
</span><span id="line-420"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookup"><span class="hs-identifier hs-type">tcLookup</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTyThing"><span class="hs-identifier hs-type">TcTyThing</span></a></span><span>
</span><span id="line-421"></span><span id="tcLookup"><span class="annot"><span class="annottext">tcLookup :: Name -&gt; TcM TcTyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookup"><span class="hs-identifier hs-var hs-var">tcLookup</span></a></span></span><span> </span><span id="local-6989586621681083520"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083520"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-422"></span><span>    </span><span id="local-6989586621681083519"><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083519"><span class="hs-identifier hs-var">local_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcTypeEnv
</span><a href="GHC.Tc.Utils.Monad.html#getLclTypeEnv"><span class="hs-identifier hs-var">getLclTypeEnv</span></a></span><span>
</span><span id="line-423"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTypeEnv -&gt; Name -&gt; Maybe TcTyThing
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083519"><span class="hs-identifier hs-var">local_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083520"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-424"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681083518"><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083518"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcTyThing -&gt; TcM TcTyThing
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083518"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-425"></span><span>        </span><span class="annot"><span class="annottext">Maybe TcTyThing
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyThing -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-var">AGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">(TyThing -&gt; TcTyThing) -&gt; TcM TyThing -&gt; TcM TcTyThing
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookupGlobal"><span class="hs-identifier hs-var">tcLookupGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083520"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-426"></span><span>
</span><span id="line-427"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupTyVar"><span class="hs-identifier hs-type">tcLookupTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-428"></span><span id="tcLookupTyVar"><span class="annot"><span class="annottext">tcLookupTyVar :: Name -&gt; TcM Id
</span><a href="GHC.Tc.Utils.Env.html#tcLookupTyVar"><span class="hs-identifier hs-var hs-var">tcLookupTyVar</span></a></span></span><span> </span><span id="local-6989586621681083515"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083515"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-429"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083514"><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083514"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TcTyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookup"><span class="hs-identifier hs-var">tcLookup</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083515"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-430"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083514"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-431"></span><span>           </span><span class="annot"><a href="GHC.Tc.Types.html#ATyVar"><span class="hs-identifier hs-type">ATyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681083512"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083512"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcM Id
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083512"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-432"></span><span>           </span><span class="annot"><span class="annottext">TcTyThing
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; TcM Id
forall a. HasCallStack =&gt; String -&gt; MsgDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcLookupTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083515"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-433"></span><span>
</span><span id="line-434"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupId"><span class="hs-identifier hs-type">tcLookupId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-435"></span><span class="hs-comment">-- Used when we aren't interested in the binding level, nor refinement.</span><span>
</span><span id="line-436"></span><span class="hs-comment">-- The &quot;no refinement&quot; part means that we return the un-refined Id regardless</span><span>
</span><span id="line-437"></span><span class="hs-comment">--</span><span>
</span><span id="line-438"></span><span class="hs-comment">-- The Id is never a DataCon. (Why does that matter? see GHC.Tc.Gen.Expr.tcId)</span><span>
</span><span id="line-439"></span><span id="tcLookupId"><span class="annot"><span class="annottext">tcLookupId :: Name -&gt; TcM Id
</span><a href="GHC.Tc.Utils.Env.html#tcLookupId"><span class="hs-identifier hs-var hs-var">tcLookupId</span></a></span></span><span> </span><span id="local-6989586621681083511"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083511"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-440"></span><span>    </span><span id="local-6989586621681083510"><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681083510"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM (Maybe Id)
</span><a href="GHC.Tc.Utils.Env.html#tcLookupIdMaybe"><span class="hs-identifier hs-var">tcLookupIdMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083511"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-441"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681083510"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-442"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681083509"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083509"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcM Id
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083509"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-443"></span><span>        </span><span class="annot"><span class="annottext">Maybe Id
</span><span class="hs-identifier">_</span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; TcM Id
forall a. HasCallStack =&gt; String -&gt; MsgDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcLookupId&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083511"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-444"></span><span>
</span><span id="line-445"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupIdMaybe"><span class="hs-identifier hs-type">tcLookupIdMaybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-446"></span><span id="tcLookupIdMaybe"><span class="annot"><span class="annottext">tcLookupIdMaybe :: Name -&gt; TcM (Maybe Id)
</span><a href="GHC.Tc.Utils.Env.html#tcLookupIdMaybe"><span class="hs-identifier hs-var hs-var">tcLookupIdMaybe</span></a></span></span><span> </span><span id="local-6989586621681083508"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083508"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-447"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083507"><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083507"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TcTyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookup"><span class="hs-identifier hs-var">tcLookup</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083508"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-448"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083507"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-449"></span><span>           </span><span class="annot"><a href="GHC.Tc.Types.html#ATcId"><span class="hs-identifier hs-type">ATcId</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tct_id :: TcTyThing -&gt; Id
</span><a href="GHC.Tc.Types.html#tct_id"><span class="hs-identifier hs-var">tct_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083504"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083504"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Id -&gt; TcM (Maybe Id)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Id -&gt; TcM (Maybe Id)) -&gt; Maybe Id -&gt; TcM (Maybe Id)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Id
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083504"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-450"></span><span>           </span><span class="annot"><a href="GHC.Tc.Types.html#AGlobal"><span class="hs-identifier hs-type">AGlobal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AnId"><span class="hs-identifier hs-type">AnId</span></a></span><span> </span><span id="local-6989586621681083503"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083503"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Id -&gt; TcM (Maybe Id)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Id -&gt; TcM (Maybe Id)) -&gt; Maybe Id -&gt; TcM (Maybe Id)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Id
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083503"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-451"></span><span>           </span><span class="annot"><span class="annottext">TcTyThing
</span><span class="hs-identifier">_</span></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Id -&gt; TcM (Maybe Id)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Id
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-452"></span><span>
</span><span id="line-453"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupLocalIds"><span class="hs-identifier hs-type">tcLookupLocalIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-454"></span><span class="hs-comment">-- We expect the variables to all be bound, and all at</span><span>
</span><span id="line-455"></span><span class="hs-comment">-- the same level as the lookup.  Only used in one place...</span><span>
</span><span id="line-456"></span><span id="tcLookupLocalIds"><span class="annot"><span class="annottext">tcLookupLocalIds :: [Name] -&gt; TcM [Id]
</span><a href="GHC.Tc.Utils.Env.html#tcLookupLocalIds"><span class="hs-identifier hs-var hs-var">tcLookupLocalIds</span></a></span></span><span> </span><span id="local-6989586621681083502"><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681083502"><span class="hs-identifier hs-var">ns</span></a></span></span><span>
</span><span id="line-457"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083501"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083501"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcLclEnv
forall gbl lcl. TcRnIf gbl lcl lcl
</span><a href="GHC.Tc.Utils.Monad.html#getLclEnv"><span class="hs-identifier hs-var">getLclEnv</span></a></span><span>
</span><span id="line-458"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; TcM [Id]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Name -&gt; Id) -&gt; [Name] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTypeEnv -&gt; Name -&gt; Id
</span><a href="#local-6989586621681083499"><span class="hs-identifier hs-var">lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLclEnv -&gt; TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var hs-var">tcl_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083501"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681083502"><span class="hs-identifier hs-var">ns</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-459"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-460"></span><span>    </span><span id="local-6989586621681083499"><span class="annot"><span class="annottext">lookup :: TcTypeEnv -&gt; Name -&gt; Id
</span><a href="#local-6989586621681083499"><span class="hs-identifier hs-var hs-var">lookup</span></a></span></span><span> </span><span id="local-6989586621681083494"><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083494"><span class="hs-identifier hs-var">lenv</span></a></span></span><span> </span><span id="local-6989586621681083493"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083493"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-461"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTypeEnv -&gt; Name -&gt; Maybe TcTyThing
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083494"><span class="hs-identifier hs-var">lenv</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083493"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-462"></span><span>                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#ATcId"><span class="hs-identifier hs-type">ATcId</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tct_id :: TcTyThing -&gt; Id
</span><a href="GHC.Tc.Types.html#tct_id"><span class="hs-identifier hs-var">tct_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083492"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083492"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>  </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083492"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-463"></span><span>                </span><span class="annot"><span class="annottext">Maybe TcTyThing
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; Id
forall a. HasCallStack =&gt; String -&gt; MsgDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcLookupLocalIds&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083493"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-464"></span><span>
</span><span id="line-465"></span><span class="hs-comment">-- inferInitialKind has made a suitably-shaped kind for the type or class</span><span>
</span><span id="line-466"></span><span class="hs-comment">-- Look it up in the local environment. This is used only for tycons</span><span>
</span><span id="line-467"></span><span class="hs-comment">-- that we're currently type-checking, so we're sure to find a TcTyCon.</span><span>
</span><span id="line-468"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcLookupTcTyCon"><span class="hs-identifier hs-type">tcLookupTcTyCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCon"><span class="hs-identifier hs-type">TcTyCon</span></a></span><span>
</span><span id="line-469"></span><span id="tcLookupTcTyCon"><span class="annot"><span class="annottext">tcLookupTcTyCon :: HasDebugCallStack =&gt; Name -&gt; TcM TyCon
</span><a href="GHC.Tc.Utils.Env.html#tcLookupTcTyCon"><span class="hs-identifier hs-var hs-var">tcLookupTcTyCon</span></a></span></span><span> </span><span id="local-6989586621681083484"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083484"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-470"></span><span>    </span><span id="local-6989586621681083483"><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083483"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TcTyThing
</span><a href="GHC.Tc.Utils.Env.html#tcLookup"><span class="hs-identifier hs-var">tcLookup</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083484"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-471"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083483"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-472"></span><span>        </span><span class="annot"><a href="GHC.Tc.Types.html#ATcTyCon"><span class="hs-identifier hs-type">ATcTyCon</span></a></span><span> </span><span id="local-6989586621681083481"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083481"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TcM TyCon
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083481"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-473"></span><span>        </span><span class="annot"><span class="annottext">TcTyThing
</span><span class="hs-identifier">_</span></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; TcM TyCon
forall a. HasCallStack =&gt; String -&gt; MsgDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcLookupTcTyCon&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083484"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-474"></span><span>
</span><span id="line-475"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#getInLocalScope"><span class="hs-identifier hs-type">getInLocalScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span>
</span><span id="line-476"></span><span id="getInLocalScope"><span class="annot"><span class="annottext">getInLocalScope :: TcM (Name -&gt; Bool)
</span><a href="GHC.Tc.Utils.Env.html#getInLocalScope"><span class="hs-identifier hs-var hs-var">getInLocalScope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083480"><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083480"><span class="hs-identifier hs-var">lcl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcTypeEnv
</span><a href="GHC.Tc.Utils.Monad.html#getLclTypeEnv"><span class="hs-identifier hs-var">getLclTypeEnv</span></a></span><span>
</span><span id="line-477"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Bool) -&gt; TcM (Name -&gt; Bool)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; TcTypeEnv -&gt; Bool
forall a. Name -&gt; NameEnv a -&gt; Bool
</span><a href="GHC.Types.Name.Env.html#elemNameEnv"><span class="hs-operator hs-var">`elemNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083480"><span class="hs-identifier hs-var">lcl_env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-478"></span><span>
</span><span id="line-479"></span><span id="local-6989586621681084108"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendKindEnvList"><span class="hs-identifier hs-type">tcExtendKindEnvList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTyThing"><span class="hs-identifier hs-type">TcTyThing</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084108"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084108"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-480"></span><span class="hs-comment">-- Used only during kind checking, for TcThings that are</span><span>
</span><span id="line-481"></span><span class="hs-comment">--      ATcTyCon or APromotionErr</span><span>
</span><span id="line-482"></span><span class="hs-comment">-- No need to update the global tyvars, or tcl_th_bndrs, or tcl_rdr</span><span>
</span><span id="line-483"></span><span id="tcExtendKindEnvList"><span class="annot"><span class="annottext">tcExtendKindEnvList :: forall r. [(Name, TcTyThing)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendKindEnvList"><span class="hs-identifier hs-var hs-var">tcExtendKindEnvList</span></a></span></span><span> </span><span id="local-6989586621681083473"><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083473"><span class="hs-identifier hs-var">things</span></a></span></span><span> </span><span id="local-6989586621681083472"><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083472"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-484"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcExtendKindEnvList&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Name, TcTyThing)] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083473"><span class="hs-identifier hs-var">things</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-485"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcLclEnv -&gt; TcLclEnv) -&gt; TcM r -&gt; TcM r
forall lcl gbl a.
(lcl -&gt; lcl) -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#updLclEnv"><span class="hs-identifier hs-var">updLclEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv -&gt; TcLclEnv
</span><a href="#local-6989586621681083469"><span class="hs-identifier hs-var">upd_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083472"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-486"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-487"></span><span>    </span><span id="local-6989586621681083469"><span class="annot"><span class="annottext">upd_env :: TcLclEnv -&gt; TcLclEnv
</span><a href="#local-6989586621681083469"><span class="hs-identifier hs-var hs-var">upd_env</span></a></span></span><span> </span><span id="local-6989586621681083468"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083468"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083468"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcl_env :: TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var">tcl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTypeEnv -&gt; [(Name, TcTyThing)] -&gt; TcTypeEnv
forall a. NameEnv a -&gt; [(Name, a)] -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#extendNameEnvList"><span class="hs-identifier hs-var">extendNameEnvList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLclEnv -&gt; TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var hs-var">tcl_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083468"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083473"><span class="hs-identifier hs-var">things</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-488"></span><span>
</span><span id="line-489"></span><span id="local-6989586621681084100"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendKindEnv"><span class="hs-identifier hs-type">tcExtendKindEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Env.html#NameEnv"><span class="hs-identifier hs-type">NameEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTyThing"><span class="hs-identifier hs-type">TcTyThing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084100"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084100"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-490"></span><span class="hs-comment">-- A variant of tcExtendKindEvnList</span><span>
</span><span id="line-491"></span><span id="tcExtendKindEnv"><span class="annot"><span class="annottext">tcExtendKindEnv :: forall r. TcTypeEnv -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendKindEnv"><span class="hs-identifier hs-var hs-var">tcExtendKindEnv</span></a></span></span><span> </span><span id="local-6989586621681083465"><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083465"><span class="hs-identifier hs-var">extra_env</span></a></span></span><span> </span><span id="local-6989586621681083464"><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083464"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-492"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcExtendKindEnv&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTypeEnv -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083465"><span class="hs-identifier hs-var">extra_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-493"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcLclEnv -&gt; TcLclEnv) -&gt; TcM r -&gt; TcM r
forall lcl gbl a.
(lcl -&gt; lcl) -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#updLclEnv"><span class="hs-identifier hs-var">updLclEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv -&gt; TcLclEnv
</span><a href="#local-6989586621681083463"><span class="hs-identifier hs-var">upd_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083464"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-494"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-495"></span><span>    </span><span id="local-6989586621681083463"><span class="annot"><span class="annottext">upd_env :: TcLclEnv -&gt; TcLclEnv
</span><a href="#local-6989586621681083463"><span class="hs-identifier hs-var hs-var">upd_env</span></a></span></span><span> </span><span id="local-6989586621681083462"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083462"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083462"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcl_env :: TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var">tcl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLclEnv -&gt; TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var hs-var">tcl_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083462"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv -&gt; TcTypeEnv -&gt; TcTypeEnv
forall a. NameEnv a -&gt; NameEnv a -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#plusNameEnv"><span class="hs-operator hs-var">`plusNameEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083465"><span class="hs-identifier hs-var">extra_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-496"></span><span>
</span><span id="line-497"></span><span class="hs-comment">-----------------------</span><span>
</span><span id="line-498"></span><span class="hs-comment">-- Scoped type and kind variables</span><span>
</span><span id="line-499"></span><span id="local-6989586621681083460"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendTyVarEnv"><span class="hs-identifier hs-type">tcExtendTyVarEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083460"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083460"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-500"></span><span id="tcExtendTyVarEnv"><span class="annot"><span class="annottext">tcExtendTyVarEnv :: forall a. [Id] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendTyVarEnv"><span class="hs-identifier hs-var hs-var">tcExtendTyVarEnv</span></a></span></span><span> </span><span id="local-6989586621681083458"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083458"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681083457"><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083457"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-501"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)] -&gt; TcM r -&gt; TcM r
forall r. [(Name, Id)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendNameTyVarEnv"><span class="hs-identifier hs-var">tcExtendNameTyVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [(Name, Id)]
</span><a href="GHC.Tc.Utils.TcType.html#mkTyVarNamePairs"><span class="hs-identifier hs-var">mkTyVarNamePairs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083458"><span class="hs-identifier hs-var">tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083457"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-502"></span><span>
</span><span id="line-503"></span><span id="local-6989586621681084096"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendNameTyVarEnv"><span class="hs-identifier hs-type">tcExtendNameTyVarEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084096"><span class="hs-identifier hs-type">r</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084096"><span class="hs-identifier hs-type">r</span></a></span></span><span>
</span><span id="line-504"></span><span id="tcExtendNameTyVarEnv"><span class="annot"><span class="annottext">tcExtendNameTyVarEnv :: forall r. [(Name, Id)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendNameTyVarEnv"><span class="hs-identifier hs-var hs-var">tcExtendNameTyVarEnv</span></a></span></span><span> </span><span id="local-6989586621681083455"><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681083455"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621681083454"><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083454"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-505"></span><span>  </span><span class="hs-comment">-- this should be used only for explicitly mentioned scoped variables.</span><span>
</span><span id="line-506"></span><span>  </span><span class="hs-comment">-- thus, no coercion variables</span><span>
</span><span id="line-507"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM r -&gt; TcM r
forall a. TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tc_extend_local_env"><span class="hs-identifier hs-var">tc_extend_local_env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#NotTopLevel"><span class="hs-identifier hs-var">NotTopLevel</span></a></span><span>
</span><span id="line-508"></span><span>                    </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083451"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Id -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#ATyVar"><span class="hs-identifier hs-var">ATyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083451"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083450"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083451"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083451"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681083450"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083450"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681083455"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(TcM r -&gt; TcM r) -&gt; TcM r -&gt; TcM r
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-509"></span><span>         </span><span class="annot"><span class="annottext">[TcBinder] -&gt; TcM r -&gt; TcM r
forall a. [TcBinder] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendBinderStack"><span class="hs-identifier hs-var">tcExtendBinderStack</span></a></span><span> </span><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681083449"><span class="hs-identifier hs-var">tv_binds</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM r -&gt; TcM r) -&gt; TcM r -&gt; TcM r
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-510"></span><span>         </span><span class="annot"><span class="annottext">TcM r
</span><a href="#local-6989586621681083454"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-511"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-512"></span><span>    </span><span class="annot"><a href="#local-6989586621681083449"><span class="hs-identifier hs-type">tv_binds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcBinder"><span class="hs-identifier hs-type">TcBinder</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-513"></span><span>    </span><span id="local-6989586621681083449"><span class="annot"><span class="annottext">tv_binds :: [TcBinder]
</span><a href="#local-6989586621681083449"><span class="hs-identifier hs-var hs-var">tv_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Name -&gt; Id -&gt; TcBinder
</span><a href="GHC.Tc.Types.html#TcTvBndr"><span class="hs-identifier hs-var">TcTvBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083447"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083446"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083447"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083447"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681083446"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083446"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681083455"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-514"></span><span>
</span><span id="line-515"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#isTypeClosedLetBndr"><span class="hs-identifier hs-type">isTypeClosedLetBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-516"></span><span class="hs-comment">-- See Note [Bindings with closed types] in GHC.Tc.Types</span><span>
</span><span id="line-517"></span><span id="isTypeClosedLetBndr"><span class="annot"><span class="annottext">isTypeClosedLetBndr :: Id -&gt; Bool
</span><a href="GHC.Tc.Utils.Env.html#isTypeClosedLetBndr"><span class="hs-identifier hs-var hs-var">isTypeClosedLetBndr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.TyCo.FVs.html#noFreeVarsOfType"><span class="hs-identifier hs-var">noFreeVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; (Id -&gt; Type) -&gt; Id -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span>
</span><span id="line-518"></span><span>
</span><span id="line-519"></span><span id="local-6989586621681083442"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendRecIds"><span class="hs-identifier hs-type">tcExtendRecIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083442"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083442"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-520"></span><span class="hs-comment">-- Used for binding the recursive uses of Ids in a binding</span><span>
</span><span id="line-521"></span><span class="hs-comment">-- both top-level value bindings and nested let/where-bindings</span><span>
</span><span id="line-522"></span><span class="hs-comment">-- Does not extend the TcBinderStack</span><span>
</span><span id="line-523"></span><span id="tcExtendRecIds"><span class="annot"><span class="annottext">tcExtendRecIds :: forall r. [(Name, Id)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendRecIds"><span class="hs-identifier hs-var hs-var">tcExtendRecIds</span></a></span></span><span> </span><span id="local-6989586621681083441"><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681083441"><span class="hs-identifier hs-var">pairs</span></a></span></span><span> </span><span id="local-6989586621681083440"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083440"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-524"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
forall a. TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tc_extend_local_env"><span class="hs-identifier hs-var">tc_extend_local_env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#NotTopLevel"><span class="hs-identifier hs-var">NotTopLevel</span></a></span><span>
</span><span id="line-525"></span><span>          </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083439"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ATcId :: Id -&gt; IdBindingInfo -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#ATcId"><span class="hs-identifier hs-type">ATcId</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tct_id :: Id
</span><a href="GHC.Tc.Types.html#tct_id"><span class="hs-identifier hs-var">tct_id</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083438"><span class="hs-identifier hs-var">let_id</span></a></span><span>
</span><span id="line-526"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tct_info :: IdBindingInfo
</span><a href="GHC.Tc.Types.html#tct_info"><span class="hs-identifier hs-var">tct_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RhsNames -&gt; Bool -&gt; IdBindingInfo
</span><a href="GHC.Tc.Types.html#NonClosedLet"><span class="hs-identifier hs-var">NonClosedLet</span></a></span><span> </span><span class="annot"><span class="annottext">RhsNames
</span><a href="GHC.Types.Name.Set.html#emptyNameSet"><span class="hs-identifier hs-var">emptyNameSet</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-527"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083439"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083439"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681083438"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083438"><span class="hs-identifier hs-var">let_id</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681083441"><span class="hs-identifier hs-var">pairs</span></a></span><span> </span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(TcM a -&gt; TcM a) -&gt; TcM a -&gt; TcM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-528"></span><span>    </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083440"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-529"></span><span>
</span><span id="line-530"></span><span id="local-6989586621681084084"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendSigIds"><span class="hs-identifier hs-type">tcExtendSigIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084084"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084084"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-531"></span><span class="hs-comment">-- Used for binding the Ids that have a complete user type signature</span><span>
</span><span id="line-532"></span><span class="hs-comment">-- Does not extend the TcBinderStack</span><span>
</span><span id="line-533"></span><span id="tcExtendSigIds"><span class="annot"><span class="annottext">tcExtendSigIds :: forall a. TopLevelFlag -&gt; [Id] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendSigIds"><span class="hs-identifier hs-var hs-var">tcExtendSigIds</span></a></span></span><span> </span><span id="local-6989586621681083434"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621681083434"><span class="hs-identifier hs-var">top_lvl</span></a></span></span><span> </span><span id="local-6989586621681083433"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083433"><span class="hs-identifier hs-var">sig_ids</span></a></span></span><span> </span><span id="local-6989586621681083432"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083432"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-534"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
forall a. TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tc_extend_local_env"><span class="hs-identifier hs-var">tc_extend_local_env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621681083434"><span class="hs-identifier hs-var">top_lvl</span></a></span><span>
</span><span id="line-535"></span><span>          </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083430"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ATcId :: Id -&gt; IdBindingInfo -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#ATcId"><span class="hs-identifier hs-type">ATcId</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tct_id :: Id
</span><a href="GHC.Tc.Types.html#tct_id"><span class="hs-identifier hs-var">tct_id</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083430"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-536"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tct_info :: IdBindingInfo
</span><a href="GHC.Tc.Types.html#tct_info"><span class="hs-identifier hs-var">tct_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdBindingInfo
</span><a href="#local-6989586621681083429"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-537"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681083430"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083430"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083433"><span class="hs-identifier hs-var">sig_ids</span></a></span><span>
</span><span id="line-538"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083428"><span class="annot"><span class="annottext">closed :: Bool
</span><a href="#local-6989586621681083428"><span class="hs-identifier hs-var hs-var">closed</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Tc.Utils.Env.html#isTypeClosedLetBndr"><span class="hs-identifier hs-var">isTypeClosedLetBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083430"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-539"></span><span>                </span><span id="local-6989586621681083429"><span class="annot"><span class="annottext">info :: IdBindingInfo
</span><a href="#local-6989586621681083429"><span class="hs-identifier hs-var hs-var">info</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RhsNames -&gt; Bool -&gt; IdBindingInfo
</span><a href="GHC.Tc.Types.html#NonClosedLet"><span class="hs-identifier hs-var">NonClosedLet</span></a></span><span> </span><span class="annot"><span class="annottext">RhsNames
</span><a href="GHC.Types.Name.Set.html#emptyNameSet"><span class="hs-identifier hs-var">emptyNameSet</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083428"><span class="hs-identifier hs-var">closed</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-540"></span><span>     </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083432"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-541"></span><span>
</span><span id="line-542"></span><span>
</span><span id="line-543"></span><span id="local-6989586621681084080"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendLetEnv"><span class="hs-identifier hs-type">tcExtendLetEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcSigFun"><span class="hs-identifier hs-type">TcSigFun</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#IsGroupClosed"><span class="hs-identifier hs-type">IsGroupClosed</span></a></span><span>
</span><span id="line-544"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084080"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084080"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-545"></span><span class="hs-comment">-- Used for both top-level value bindings and nested let/where-bindings</span><span>
</span><span id="line-546"></span><span class="hs-comment">-- Adds to the TcBinderStack too</span><span>
</span><span id="line-547"></span><span id="tcExtendLetEnv"><span class="annot"><span class="annottext">tcExtendLetEnv :: forall a.
TopLevelFlag -&gt; TcSigFun -&gt; IsGroupClosed -&gt; [Id] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendLetEnv"><span class="hs-identifier hs-var hs-var">tcExtendLetEnv</span></a></span></span><span> </span><span id="local-6989586621681083427"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621681083427"><span class="hs-identifier hs-var">top_lvl</span></a></span></span><span> </span><span id="local-6989586621681083426"><span class="annot"><span class="annottext">TcSigFun
</span><a href="#local-6989586621681083426"><span class="hs-identifier hs-var">sig_fn</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#IsGroupClosed"><span class="hs-identifier hs-type">IsGroupClosed</span></a></span><span> </span><span id="local-6989586621681083424"><span class="annot"><span class="annottext">NameEnv RhsNames
</span><a href="#local-6989586621681083424"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span id="local-6989586621681083423"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083423"><span class="hs-identifier hs-var">fv_type_closed</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-548"></span><span>               </span><span id="local-6989586621681083422"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083422"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621681083421"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083421"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-549"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcBinder] -&gt; TcM a -&gt; TcM a
forall a. [TcBinder] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendBinderStack"><span class="hs-identifier hs-var">tcExtendBinderStack</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id -&gt; TopLevelFlag -&gt; TcBinder
</span><a href="GHC.Tc.Types.html#TcIdBndr"><span class="hs-identifier hs-var">TcIdBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083419"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621681083427"><span class="hs-identifier hs-var">top_lvl</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681083419"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083419"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083422"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(TcM a -&gt; TcM a) -&gt; TcM a -&gt; TcM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-550"></span><span>    </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
forall a. TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tc_extend_local_env"><span class="hs-identifier hs-var">tc_extend_local_env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621681083427"><span class="hs-identifier hs-var">top_lvl</span></a></span><span>
</span><span id="line-551"></span><span>          </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083418"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ATcId :: Id -&gt; IdBindingInfo -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#ATcId"><span class="hs-identifier hs-type">ATcId</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tct_id :: Id
</span><a href="GHC.Tc.Types.html#tct_id"><span class="hs-identifier hs-var">tct_id</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083418"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-552"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tct_info :: IdBindingInfo
</span><a href="GHC.Tc.Types.html#tct_info"><span class="hs-identifier hs-var">tct_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; IdBindingInfo
</span><a href="#local-6989586621681083417"><span class="hs-identifier hs-var">mk_tct_info</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083418"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-553"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681083418"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083418"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083422"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-554"></span><span>    </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083421"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-555"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-556"></span><span>    </span><span id="local-6989586621681083417"><span class="annot"><span class="annottext">mk_tct_info :: Id -&gt; IdBindingInfo
</span><a href="#local-6989586621681083417"><span class="hs-identifier hs-var hs-var">mk_tct_info</span></a></span></span><span> </span><span id="local-6989586621681083416"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083416"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-557"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083415"><span class="hs-identifier hs-var">type_closed</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">RhsNames -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#isEmptyNameSet"><span class="hs-identifier hs-var">isEmptyNameSet</span></a></span><span> </span><span class="annot"><span class="annottext">RhsNames
</span><a href="#local-6989586621681083413"><span class="hs-identifier hs-var">rhs_fvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdBindingInfo
</span><a href="GHC.Tc.Types.html#ClosedLet"><span class="hs-identifier hs-var">ClosedLet</span></a></span><span>
</span><span id="line-558"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RhsNames -&gt; Bool -&gt; IdBindingInfo
</span><a href="GHC.Tc.Types.html#NonClosedLet"><span class="hs-identifier hs-var">NonClosedLet</span></a></span><span> </span><span class="annot"><span class="annottext">RhsNames
</span><a href="#local-6989586621681083413"><span class="hs-identifier hs-var">rhs_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083415"><span class="hs-identifier hs-var">type_closed</span></a></span><span>
</span><span id="line-559"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-560"></span><span>        </span><span id="local-6989586621681083411"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621681083411"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083416"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-561"></span><span>        </span><span id="local-6989586621681083413"><span class="annot"><span class="annottext">rhs_fvs :: RhsNames
</span><a href="#local-6989586621681083413"><span class="hs-identifier hs-var hs-var">rhs_fvs</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameEnv RhsNames -&gt; Name -&gt; Maybe RhsNames
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv RhsNames
</span><a href="#local-6989586621681083424"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083411"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe RhsNames -&gt; RhsNames -&gt; RhsNames
forall a. Maybe a -&gt; a -&gt; a
</span><a href="GHC.Data.Maybe.html#orElse"><span class="hs-operator hs-var">`orElse`</span></a></span><span> </span><span class="annot"><span class="annottext">RhsNames
</span><a href="GHC.Types.Name.Set.html#emptyNameSet"><span class="hs-identifier hs-var">emptyNameSet</span></a></span><span>
</span><span id="line-562"></span><span>        </span><span id="local-6989586621681083415"><span class="annot"><span class="annottext">type_closed :: Bool
</span><a href="#local-6989586621681083415"><span class="hs-identifier hs-var hs-var">type_closed</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Tc.Utils.Env.html#isTypeClosedLetBndr"><span class="hs-identifier hs-var">isTypeClosedLetBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083416"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-563"></span><span>                      </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083423"><span class="hs-identifier hs-var">fv_type_closed</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">TcSigFun -&gt; Name -&gt; Bool
</span><a href="GHC.Tc.Types.html#hasCompleteSig"><span class="hs-identifier hs-var">hasCompleteSig</span></a></span><span> </span><span class="annot"><span class="annottext">TcSigFun
</span><a href="#local-6989586621681083426"><span class="hs-identifier hs-var">sig_fn</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083411"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-564"></span><span>
</span><span id="line-565"></span><span id="local-6989586621681083408"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv"><span class="hs-identifier hs-type">tcExtendIdEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083408"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083408"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-566"></span><span class="hs-comment">-- For lambda-bound and case-bound Ids</span><span>
</span><span id="line-567"></span><span class="hs-comment">-- Extends the TcBinderStack as well</span><span>
</span><span id="line-568"></span><span id="tcExtendIdEnv"><span class="annot"><span class="annottext">tcExtendIdEnv :: forall a. [Id] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv"><span class="hs-identifier hs-var hs-var">tcExtendIdEnv</span></a></span></span><span> </span><span id="local-6989586621681083407"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083407"><span class="hs-identifier hs-var">ids</span></a></span></span><span> </span><span id="local-6989586621681083406"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083406"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-569"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)] -&gt; TcM a -&gt; TcM a
forall r. [(Name, Id)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv2"><span class="hs-identifier hs-var">tcExtendIdEnv2</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083405"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083405"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681083405"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083405"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083407"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083406"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-570"></span><span>
</span><span id="line-571"></span><span id="local-6989586621681084076"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv1"><span class="hs-identifier hs-type">tcExtendIdEnv1</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084076"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084076"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-572"></span><span class="hs-comment">-- Exactly like tcExtendIdEnv2, but for a single (name,id) pair</span><span>
</span><span id="line-573"></span><span id="tcExtendIdEnv1"><span class="annot"><span class="annottext">tcExtendIdEnv1 :: forall a. Name -&gt; Id -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv1"><span class="hs-identifier hs-var hs-var">tcExtendIdEnv1</span></a></span></span><span> </span><span id="local-6989586621681083404"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083404"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681083403"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083403"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621681083402"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083402"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-574"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)] -&gt; TcM a -&gt; TcM a
forall r. [(Name, Id)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv2"><span class="hs-identifier hs-var">tcExtendIdEnv2</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083404"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083403"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083402"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-575"></span><span>
</span><span id="line-576"></span><span id="local-6989586621681083401"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv2"><span class="hs-identifier hs-type">tcExtendIdEnv2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083401"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083401"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-577"></span><span id="tcExtendIdEnv2"><span class="annot"><span class="annottext">tcExtendIdEnv2 :: forall r. [(Name, Id)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendIdEnv2"><span class="hs-identifier hs-var hs-var">tcExtendIdEnv2</span></a></span></span><span> </span><span id="local-6989586621681083400"><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681083400"><span class="hs-identifier hs-var">names_w_ids</span></a></span></span><span> </span><span id="local-6989586621681083399"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083399"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-578"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcBinder] -&gt; TcM a -&gt; TcM a
forall a. [TcBinder] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendBinderStack"><span class="hs-identifier hs-var">tcExtendBinderStack</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Id -&gt; TopLevelFlag -&gt; TcBinder
</span><a href="GHC.Tc.Types.html#TcIdBndr"><span class="hs-identifier hs-var">TcIdBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083398"><span class="hs-identifier hs-var">mono_id</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#NotTopLevel"><span class="hs-identifier hs-var">NotTopLevel</span></a></span><span>
</span><span id="line-579"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681083398"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083398"><span class="hs-identifier hs-var">mono_id</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681083400"><span class="hs-identifier hs-var">names_w_ids</span></a></span><span> </span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(TcM a -&gt; TcM a) -&gt; TcM a -&gt; TcM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-580"></span><span>    </span><span class="annot"><span class="annottext">TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
forall a. TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tc_extend_local_env"><span class="hs-identifier hs-var">tc_extend_local_env</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#NotTopLevel"><span class="hs-identifier hs-var">NotTopLevel</span></a></span><span>
</span><span id="line-581"></span><span>            </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083397"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ATcId :: Id -&gt; IdBindingInfo -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#ATcId"><span class="hs-identifier hs-type">ATcId</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tct_id :: Id
</span><a href="GHC.Tc.Types.html#tct_id"><span class="hs-identifier hs-var">tct_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083396"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-582"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tct_info :: IdBindingInfo
</span><a href="GHC.Tc.Types.html#tct_info"><span class="hs-identifier hs-var">tct_info</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdBindingInfo
</span><a href="GHC.Tc.Types.html#NotLetBound"><span class="hs-identifier hs-var">NotLetBound</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-583"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083397"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083397"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681083396"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083396"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681083400"><span class="hs-identifier hs-var">names_w_ids</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-584"></span><span>    </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083399"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-585"></span><span>
</span><span id="line-586"></span><span id="local-6989586621681084093"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tc_extend_local_env"><span class="hs-identifier hs-type">tc_extend_local_env</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTyThing"><span class="hs-identifier hs-type">TcTyThing</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084093"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084093"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-587"></span><span id="tc_extend_local_env"><span class="annot"><span class="annottext">tc_extend_local_env :: forall a. TopLevelFlag -&gt; [(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tc_extend_local_env"><span class="hs-identifier hs-var hs-var">tc_extend_local_env</span></a></span></span><span> </span><span id="local-6989586621681083389"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621681083389"><span class="hs-identifier hs-var">top_lvl</span></a></span></span><span> </span><span id="local-6989586621681083388"><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083388"><span class="hs-identifier hs-var">extra_env</span></a></span></span><span> </span><span id="local-6989586621681083387"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083387"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-588"></span><span class="hs-comment">-- Precondition: the argument list extra_env has TcTyThings</span><span>
</span><span id="line-589"></span><span class="hs-comment">--               that ATcId or ATyVar, but nothing else</span><span>
</span><span id="line-590"></span><span class="hs-comment">--</span><span>
</span><span id="line-591"></span><span class="hs-comment">-- Invariant: the ATcIds are fully zonked. Reasons:</span><span>
</span><span id="line-592"></span><span class="hs-comment">--      (a) The kinds of the forall'd type variables are defaulted</span><span>
</span><span id="line-593"></span><span class="hs-comment">--          (see Kind.defaultKind, done in skolemiseQuantifiedTyVar)</span><span>
</span><span id="line-594"></span><span class="hs-comment">--      (b) There are no via-Indirect occurrences of the bound variables</span><span>
</span><span id="line-595"></span><span class="hs-comment">--          in the types, because instantiation does not look through such things</span><span>
</span><span id="line-596"></span><span class="hs-comment">--      (c) The call to tyCoVarsOfTypes is ok without looking through refs</span><span>
</span><span id="line-597"></span><span>
</span><span id="line-598"></span><span class="hs-comment">-- The second argument of type TyVarSet is a set of type variables</span><span>
</span><span id="line-599"></span><span class="hs-comment">-- that are bound together with extra_env and should not be regarded</span><span>
</span><span id="line-600"></span><span class="hs-comment">-- as free in the types of extra_env.</span><span>
</span><span id="line-601"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tc_extend_local_env&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Name, TcTyThing)] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083388"><span class="hs-identifier hs-var">extra_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-602"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083386"><span class="annot"><span class="annottext">ThStage
</span><a href="#local-6989586621681083386"><span class="hs-identifier hs-var">stage</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM ThStage
</span><a href="GHC.Tc.Utils.Monad.html#getStage"><span class="hs-identifier hs-var">getStage</span></a></span><span>
</span><span id="line-603"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083384"><span class="annot"><span class="annottext">env0 :: TcLclEnv
</span><a href="#local-6989586621681083384"><span class="hs-identifier hs-var">env0</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#TcLclEnv"><span class="hs-identifier hs-type">TcLclEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcl_rdr :: TcLclEnv -&gt; LocalRdrEnv
</span><a href="GHC.Tc.Types.html#tcl_rdr"><span class="hs-identifier hs-var">tcl_rdr</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083381"><span class="annot"><span class="annottext">LocalRdrEnv
</span><a href="#local-6989586621681083381"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span>
</span><span id="line-604"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tcl_th_bndrs :: TcLclEnv -&gt; ThBindEnv
</span><a href="GHC.Tc.Types.html#tcl_th_bndrs"><span class="hs-identifier hs-var">tcl_th_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083379"><span class="annot"><span class="annottext">ThBindEnv
</span><a href="#local-6989586621681083379"><span class="hs-identifier hs-var">th_bndrs</span></a></span></span><span>
</span><span id="line-605"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tcl_env :: TcLclEnv -&gt; TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var">tcl_env</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083378"><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083378"><span class="hs-identifier hs-var">lcl_type_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcLclEnv
forall gbl lcl. TcRnIf gbl lcl lcl
</span><a href="GHC.Tc.Utils.Monad.html#getLclEnv"><span class="hs-identifier hs-var">getLclEnv</span></a></span><span>
</span><span id="line-606"></span><span>
</span><span id="line-607"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083377"><span class="annot"><span class="annottext">thlvl :: (TopLevelFlag, ThLevel)
</span><a href="#local-6989586621681083377"><span class="hs-identifier hs-var hs-var">thlvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621681083389"><span class="hs-identifier hs-var">top_lvl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThStage -&gt; ThLevel
</span><a href="GHC.Tc.Types.html#thLevel"><span class="hs-identifier hs-var">thLevel</span></a></span><span> </span><span class="annot"><span class="annottext">ThStage
</span><a href="#local-6989586621681083386"><span class="hs-identifier hs-var">stage</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-608"></span><span>
</span><span id="line-609"></span><span>              </span><span id="local-6989586621681083376"><span class="annot"><span class="annottext">env1 :: TcLclEnv
</span><a href="#local-6989586621681083376"><span class="hs-identifier hs-var hs-var">env1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083384"><span class="hs-identifier hs-var">env0</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcl_rdr :: LocalRdrEnv
</span><a href="GHC.Tc.Types.html#tcl_rdr"><span class="hs-identifier hs-var">tcl_rdr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LocalRdrEnv -&gt; [Name] -&gt; LocalRdrEnv
</span><a href="GHC.Types.Name.Reader.html#extendLocalRdrEnvList"><span class="hs-identifier hs-var">extendLocalRdrEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">LocalRdrEnv
</span><a href="#local-6989586621681083381"><span class="hs-identifier hs-var">rdr_env</span></a></span><span>
</span><span id="line-610"></span><span>                                      </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083374"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083374"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083374"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcTyThing
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083388"><span class="hs-identifier hs-var">extra_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isInternalName"><span class="hs-identifier hs-var">isInternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083374"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-611"></span><span>                                      </span><span class="hs-comment">-- The LocalRdrEnv contains only non-top-level names</span><span>
</span><span id="line-612"></span><span>                                      </span><span class="hs-comment">-- (GlobalRdrEnv handles the top level)</span><span>
</span><span id="line-613"></span><span>
</span><span id="line-614"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tcl_th_bndrs :: ThBindEnv
</span><a href="GHC.Tc.Types.html#tcl_th_bndrs"><span class="hs-identifier hs-var">tcl_th_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ThBindEnv -&gt; [(Name, (TopLevelFlag, ThLevel))] -&gt; ThBindEnv
forall a. NameEnv a -&gt; [(Name, a)] -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#extendNameEnvList"><span class="hs-identifier hs-var">extendNameEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">ThBindEnv
</span><a href="#local-6989586621681083379"><span class="hs-identifier hs-var">th_bndrs</span></a></span><span>
</span><span id="line-615"></span><span>                                          </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083372"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(TopLevelFlag, ThLevel)
</span><a href="#local-6989586621681083377"><span class="hs-identifier hs-var">thlvl</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083372"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083372"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#ATcId"><span class="hs-identifier hs-type">ATcId</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083388"><span class="hs-identifier hs-var">extra_env</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-616"></span><span>                                          </span><span class="hs-comment">-- We only track Ids in tcl_th_bndrs</span><span>
</span><span id="line-617"></span><span>
</span><span id="line-618"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tcl_env :: TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var">tcl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTypeEnv -&gt; [(Name, TcTyThing)] -&gt; TcTypeEnv
forall a. NameEnv a -&gt; [(Name, a)] -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#extendNameEnvList"><span class="hs-identifier hs-var">extendNameEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083378"><span class="hs-identifier hs-var">lcl_type_env</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083388"><span class="hs-identifier hs-var">extra_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-619"></span><span>
</span><span id="line-620"></span><span>              </span><span class="hs-comment">-- tcl_rdr and tcl_th_bndrs: extend the local LocalRdrEnv and</span><span>
</span><span id="line-621"></span><span>              </span><span class="hs-comment">-- Template Haskell staging env simultaneously. Reason for extending</span><span>
</span><span id="line-622"></span><span>              </span><span class="hs-comment">-- LocalRdrEnv: after running a TH splice we need to do renaming.</span><span>
</span><span id="line-623"></span><span>
</span><span id="line-624"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcLclEnv -&gt; TcM a -&gt; TcM a
forall lcl' gbl a lcl.
lcl' -&gt; TcRnIf gbl lcl' a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setLclEnv"><span class="hs-identifier hs-var">setLclEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083376"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083387"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-625"></span><span>
</span><span id="line-626"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendLocalTypeEnv"><span class="hs-identifier hs-type">tcExtendLocalTypeEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcLclEnv"><span class="hs-identifier hs-type">TcLclEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTyThing"><span class="hs-identifier hs-type">TcTyThing</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcLclEnv"><span class="hs-identifier hs-type">TcLclEnv</span></a></span><span>
</span><span id="line-627"></span><span id="tcExtendLocalTypeEnv"><span class="annot"><span class="annottext">tcExtendLocalTypeEnv :: TcLclEnv -&gt; [(Name, TcTyThing)] -&gt; TcLclEnv
</span><a href="GHC.Tc.Utils.Env.html#tcExtendLocalTypeEnv"><span class="hs-identifier hs-var hs-var">tcExtendLocalTypeEnv</span></a></span></span><span> </span><span id="local-6989586621681083370"><span class="annot"><span class="annottext">lcl_env :: TcLclEnv
</span><a href="#local-6989586621681083370"><span class="hs-identifier hs-var">lcl_env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#TcLclEnv"><span class="hs-identifier hs-type">TcLclEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcl_env :: TcLclEnv -&gt; TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var">tcl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083369"><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083369"><span class="hs-identifier hs-var">lcl_type_env</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681083368"><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083368"><span class="hs-identifier hs-var">tc_ty_things</span></a></span></span><span>
</span><span id="line-628"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083370"><span class="hs-identifier hs-var">lcl_env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcl_env :: TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var">tcl_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTypeEnv -&gt; [(Name, TcTyThing)] -&gt; TcTypeEnv
forall a. NameEnv a -&gt; [(Name, a)] -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#extendNameEnvList"><span class="hs-identifier hs-var">extendNameEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv
</span><a href="#local-6989586621681083369"><span class="hs-identifier hs-var">lcl_type_env</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyThing)]
</span><a href="#local-6989586621681083368"><span class="hs-identifier hs-var">tc_ty_things</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-629"></span><span>
</span><span id="line-630"></span><span class="hs-comment">-- | @tcCheckUsage name mult thing_inside@ runs @thing_inside@, checks that the</span><span>
</span><span id="line-631"></span><span class="hs-comment">-- usage of @name@ is a submultiplicity of @mult@, and removes @name@ from the</span><span>
</span><span id="line-632"></span><span class="hs-comment">-- usage environment. See also Note [Wrapper returned from tcSubMult] in</span><span>
</span><span id="line-633"></span><span class="hs-comment">-- GHC.Tc.Utils.Unify, which applies to the wrapper returned from this function.</span><span>
</span><span id="line-634"></span><span id="local-6989586621681084065"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcCheckUsage"><span class="hs-identifier hs-type">tcCheckUsage</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084065"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681084065"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-635"></span><span id="tcCheckUsage"><span class="annot"><span class="annottext">tcCheckUsage :: forall a. Name -&gt; Type -&gt; TcM a -&gt; TcM (a, HsWrapper)
</span><a href="GHC.Tc.Utils.Env.html#tcCheckUsage"><span class="hs-identifier hs-var hs-var">tcCheckUsage</span></a></span></span><span> </span><span id="local-6989586621681083351"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083351"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681083350"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083350"><span class="hs-identifier hs-var">id_mult</span></a></span></span><span> </span><span id="local-6989586621681083349"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083349"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-636"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083348"><span class="annot"><span class="annottext">UsageEnv
</span><a href="#local-6989586621681083348"><span class="hs-identifier hs-var">local_usage</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681083347"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681083347"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM a -&gt; TcM (UsageEnv, a)
forall a. TcM a -&gt; TcM (UsageEnv, a)
</span><a href="GHC.Tc.Utils.Monad.html#tcCollectingUsage"><span class="hs-identifier hs-var">tcCollectingUsage</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083349"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-637"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083345"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681083345"><span class="hs-identifier hs-var">wrapper</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UsageEnv -&gt; TcM HsWrapper
</span><a href="#local-6989586621681083344"><span class="hs-identifier hs-var">check_then_add_usage</span></a></span><span> </span><span class="annot"><span class="annottext">UsageEnv
</span><a href="#local-6989586621681083348"><span class="hs-identifier hs-var">local_usage</span></a></span><span>
</span><span id="line-638"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(a, HsWrapper) -&gt; TcM (a, HsWrapper)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681083347"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681083345"><span class="hs-identifier hs-var">wrapper</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-639"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-640"></span><span>    </span><span class="annot"><a href="#local-6989586621681083344"><span class="hs-identifier hs-type">check_then_add_usage</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.UsageEnv.html#UsageEnv"><span class="hs-identifier hs-type">UsageEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-641"></span><span>    </span><span class="hs-comment">-- Checks that the usage of the newly introduced binder is compatible with</span><span>
</span><span id="line-642"></span><span>    </span><span class="hs-comment">-- its multiplicity, and combines the usage of non-new binders to |uenv|</span><span>
</span><span id="line-643"></span><span>    </span><span id="local-6989586621681083344"><span class="annot"><span class="annottext">check_then_add_usage :: UsageEnv -&gt; TcM HsWrapper
</span><a href="#local-6989586621681083344"><span class="hs-identifier hs-var hs-var">check_then_add_usage</span></a></span></span><span> </span><span id="local-6989586621681083343"><span class="annot"><span class="annottext">UsageEnv
</span><a href="#local-6989586621681083343"><span class="hs-identifier hs-var">uenv</span></a></span></span><span>
</span><span id="line-644"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083342"><span class="annot"><span class="annottext">actual_u :: Usage
</span><a href="#local-6989586621681083342"><span class="hs-identifier hs-var hs-var">actual_u</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UsageEnv -&gt; Name -&gt; Usage
forall n. NamedThing n =&gt; UsageEnv -&gt; n -&gt; Usage
</span><a href="GHC.Core.UsageEnv.html#lookupUE"><span class="hs-identifier hs-var">lookupUE</span></a></span><span> </span><span class="annot"><span class="annottext">UsageEnv
</span><a href="#local-6989586621681083343"><span class="hs-identifier hs-var">uenv</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083351"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-645"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;check_then_add_usage&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083350"><span class="hs-identifier hs-var">id_mult</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Usage -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Usage
</span><a href="#local-6989586621681083342"><span class="hs-identifier hs-var">actual_u</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-646"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083339"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681083339"><span class="hs-identifier hs-var">wrapper</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Usage
</span><a href="#local-6989586621681083342"><span class="hs-identifier hs-var">actual_u</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-647"></span><span>               </span><span class="annot"><span class="annottext">Usage
</span><a href="GHC.Core.UsageEnv.html#Bottom"><span class="hs-identifier hs-var">Bottom</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; TcM HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span>
</span><span id="line-648"></span><span>               </span><span class="annot"><span class="annottext">Usage
</span><a href="GHC.Core.UsageEnv.html#Zero"><span class="hs-identifier hs-var">Zero</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Type -&gt; Type -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubMult"><span class="hs-identifier hs-var">tcSubMult</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#UsageEnvironmentOf"><span class="hs-identifier hs-var">UsageEnvironmentOf</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083351"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083350"><span class="hs-identifier hs-var">id_mult</span></a></span><span>
</span><span id="line-649"></span><span>               </span><span class="annot"><a href="GHC.Core.UsageEnv.html#MUsage"><span class="hs-identifier hs-type">MUsage</span></a></span><span> </span><span id="local-6989586621681083334"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083334"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083333"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083333"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) Type
</span><a href="#local-6989586621681083332"><span class="hs-identifier hs-var">promote_mult</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083334"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-650"></span><span>                              </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Type -&gt; Type -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubMult"><span class="hs-identifier hs-var">tcSubMult</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#UsageEnvironmentOf"><span class="hs-identifier hs-var">UsageEnvironmentOf</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083351"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083333"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083350"><span class="hs-identifier hs-var">id_mult</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-651"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">UsageEnv -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#tcEmitBindingUsage"><span class="hs-identifier hs-var">tcEmitBindingUsage</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UsageEnv -&gt; Name -&gt; UsageEnv
forall n. NamedThing n =&gt; UsageEnv -&gt; n -&gt; UsageEnv
</span><a href="GHC.Core.UsageEnv.html#deleteUE"><span class="hs-identifier hs-var">deleteUE</span></a></span><span> </span><span class="annot"><span class="annottext">UsageEnv
</span><a href="#local-6989586621681083343"><span class="hs-identifier hs-var">uenv</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083351"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-652"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; TcM HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681083339"><span class="hs-identifier hs-var">wrapper</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-653"></span><span>
</span><span id="line-654"></span><span>    </span><span class="hs-comment">-- This is gross. The problem is in test case typecheck/should_compile/T18998:</span><span>
</span><span id="line-655"></span><span>    </span><span class="hs-comment">--   f :: a %1-&gt; Id n a -&gt; Id n a</span><span>
</span><span id="line-656"></span><span>    </span><span class="hs-comment">--   f x (MkId _) = MkId x</span><span>
</span><span id="line-657"></span><span>    </span><span class="hs-comment">-- where MkId is a GADT constructor. Multiplicity polymorphism of constructors</span><span>
</span><span id="line-658"></span><span>    </span><span class="hs-comment">-- invents a new multiplicity variable p[2] for the application MkId x. This</span><span>
</span><span id="line-659"></span><span>    </span><span class="hs-comment">-- variable is at level 2, bumped because of the GADT pattern-match (MkId _).</span><span>
</span><span id="line-660"></span><span>    </span><span class="hs-comment">-- We eventually unify the variable with One, due to the call to tcSubMult in</span><span>
</span><span id="line-661"></span><span>    </span><span class="hs-comment">-- tcCheckUsage. But by then, we're at TcLevel 1, and so the level-check</span><span>
</span><span id="line-662"></span><span>    </span><span class="hs-comment">-- fails.</span><span>
</span><span id="line-663"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-664"></span><span>    </span><span class="hs-comment">-- What to do? If we did inference &quot;for real&quot;, the sub-multiplicity constraint</span><span>
</span><span id="line-665"></span><span>    </span><span class="hs-comment">-- would end up in the implication of the GADT pattern-match, and all would</span><span>
</span><span id="line-666"></span><span>    </span><span class="hs-comment">-- be well. But we don't have a real sub-multiplicity constraint to put in</span><span>
</span><span id="line-667"></span><span>    </span><span class="hs-comment">-- the implication. (Multiplicity inference works outside the usual generate-</span><span>
</span><span id="line-668"></span><span>    </span><span class="hs-comment">-- constraints-and-solve scheme.) Here, where the multiplicity arrives, we</span><span>
</span><span id="line-669"></span><span>    </span><span class="hs-comment">-- must promote all multiplicity variables to reflect this outer TcLevel.</span><span>
</span><span id="line-670"></span><span>    </span><span class="hs-comment">-- It's reminiscent of floating a constraint, really, so promotion is</span><span>
</span><span id="line-671"></span><span>    </span><span class="hs-comment">-- appropriate. The promoteTcType function works only on types of kind TYPE rr,</span><span>
</span><span id="line-672"></span><span>    </span><span class="hs-comment">-- so we can't use it here. Thus, this dirtiness.</span><span>
</span><span id="line-673"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-674"></span><span>    </span><span class="hs-comment">-- It works nicely in practice.</span><span>
</span><span id="line-675"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-676"></span><span>    </span><span class="hs-comment">-- We use a set to avoid calling promoteMetaTyVarTo twice on the same</span><span>
</span><span id="line-677"></span><span>    </span><span class="hs-comment">-- metavariable. This happened in #19400.</span><span>
</span><span id="line-678"></span><span>    </span><span id="local-6989586621681083332"><span class="annot"><span class="annottext">promote_mult :: Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) Type
</span><a href="#local-6989586621681083332"><span class="hs-identifier hs-var hs-var">promote_mult</span></a></span></span><span> </span><span id="local-6989586621681083326"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083326"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083325"><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="#local-6989586621681083325"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCoVarSet -&gt; TcM TyCoVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarsAndFV"><span class="hs-identifier hs-var">zonkTyCoVarsAndFV</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; TyCoVarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083326"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-679"></span><span>                        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083322"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083322"><span class="hs-identifier hs-var">any_promoted</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCoVarSet -&gt; TcM Bool
</span><a href="GHC.Tc.Utils.TcMType.html#promoteTyVarSet"><span class="hs-identifier hs-var">promoteTyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVarSet
</span><a href="#local-6989586621681083325"><span class="hs-identifier hs-var">fvs</span></a></span><span>
</span><span id="line-680"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083322"><span class="hs-identifier hs-var">any_promoted</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) Type
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083326"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) Type
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083326"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-681"></span><span>                        </span><span class="hs-special">}</span><span>
</span><span id="line-682"></span><span>
</span><span id="line-683"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
             The TcBinderStack
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-688"></span><span>
</span><span id="line-689"></span><span id="local-6989586621681084091"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendBinderStack"><span class="hs-identifier hs-type">tcExtendBinderStack</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.html#TcBinder"><span class="hs-identifier hs-type">TcBinder</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084091"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084091"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-690"></span><span id="tcExtendBinderStack"><span class="annot"><span class="annottext">tcExtendBinderStack :: forall a. [TcBinder] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendBinderStack"><span class="hs-identifier hs-var hs-var">tcExtendBinderStack</span></a></span></span><span> </span><span id="local-6989586621681083315"><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681083315"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span id="local-6989586621681083314"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083314"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-691"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcExtendBinderStack&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TcBinder] -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681083315"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-692"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcLclEnv -&gt; TcLclEnv) -&gt; TcM a -&gt; TcM a
forall lcl gbl a.
(lcl -&gt; lcl) -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#updLclEnv"><span class="hs-identifier hs-var">updLclEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681083313"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083313"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083313"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcl_bndrs :: [TcBinder]
</span><a href="GHC.Tc.Types.html#tcl_bndrs"><span class="hs-identifier hs-var">tcl_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681083315"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[TcBinder] -&gt; [TcBinder] -&gt; [TcBinder]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv -&gt; [TcBinder]
</span><a href="GHC.Tc.Types.html#tcl_bndrs"><span class="hs-identifier hs-var hs-var">tcl_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083313"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-693"></span><span>                   </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083314"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-694"></span><span>
</span><span id="line-695"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcInitTidyEnv"><span class="hs-identifier hs-type">tcInitTidyEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span>
</span><span id="line-696"></span><span class="hs-comment">-- We initialise the &quot;tidy-env&quot;, used for tidying types before printing,</span><span>
</span><span id="line-697"></span><span class="hs-comment">-- by building a reverse map from the in-scope type variables to the</span><span>
</span><span id="line-698"></span><span class="hs-comment">-- OccName that the programmer originally used for them</span><span>
</span><span id="line-699"></span><span id="tcInitTidyEnv"><span class="annot"><span class="annottext">tcInitTidyEnv :: TcM TidyEnv
</span><a href="GHC.Tc.Utils.Env.html#tcInitTidyEnv"><span class="hs-identifier hs-var hs-var">tcInitTidyEnv</span></a></span></span><span>
</span><span id="line-700"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083311"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083311"><span class="hs-identifier hs-var">lcl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcLclEnv
forall gbl lcl. TcRnIf gbl lcl lcl
</span><a href="GHC.Tc.Utils.Monad.html#getLclEnv"><span class="hs-identifier hs-var">getLclEnv</span></a></span><span>
</span><span id="line-701"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [TcBinder] -&gt; TcM TidyEnv
</span><a href="#local-6989586621681083310"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="GHC.Types.Var.Env.html#emptyTidyEnv"><span class="hs-identifier hs-var">emptyTidyEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLclEnv -&gt; [TcBinder]
</span><a href="GHC.Tc.Types.html#tcl_bndrs"><span class="hs-identifier hs-var hs-var">tcl_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083311"><span class="hs-identifier hs-var">lcl_env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-702"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-703"></span><span>    </span><span id="local-6989586621681083310"><span class="annot"><span class="annottext">go :: TidyEnv -&gt; [TcBinder] -&gt; TcM TidyEnv
</span><a href="#local-6989586621681083310"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083304"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681083304"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681083303"><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681083303"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-704"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcM TidyEnv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681083304"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681083303"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-705"></span><span>    </span><span class="annot"><a href="#local-6989586621681083310"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083302"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681083302"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681083301"><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681083301"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083300"><span class="annot"><span class="annottext">TcBinder
</span><a href="#local-6989586621681083300"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681083299"><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681083299"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-706"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTvBndr"><span class="hs-identifier hs-type">TcTvBndr</span></a></span><span> </span><span id="local-6989586621681083298"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083298"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681083297"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083297"><span class="hs-identifier hs-var">tyvar</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcBinder
</span><a href="#local-6989586621681083300"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-707"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681083296"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681083296"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681083295"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681083295"><span class="hs-identifier hs-var">occ'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyOccEnv -&gt; OccName -&gt; (TidyOccEnv, OccName)
</span><a href="GHC.Types.Name.Occurrence.html#tidyOccName"><span class="hs-identifier hs-var">tidyOccName</span></a></span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681083302"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083298"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-708"></span><span>                  </span><span id="local-6989586621681083292"><span class="annot"><span class="annottext">name' :: Name
</span><a href="#local-6989586621681083292"><span class="hs-identifier hs-var hs-var">name'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; OccName -&gt; Name
</span><a href="GHC.Types.Name.html#tidyNameOcc"><span class="hs-identifier hs-var">tidyNameOcc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083298"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681083295"><span class="hs-identifier hs-var">occ'</span></a></span><span>
</span><span id="line-709"></span><span>                  </span><span id="local-6989586621681083290"><span class="annot"><span class="annottext">tyvar1 :: Id
</span><a href="#local-6989586621681083290"><span class="hs-identifier hs-var hs-var">tyvar1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name -&gt; Id
</span><a href="GHC.Types.Var.html#setTyVarName"><span class="hs-identifier hs-var">setTyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083297"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083292"><span class="hs-identifier hs-var">name'</span></a></span><span>
</span><span id="line-710"></span><span>            </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083288"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083288"><span class="hs-identifier hs-var">tyvar2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Id -&gt; TcM Id
Id -&gt; TcM Id
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVarToTyVar"><span class="hs-identifier hs-var">zonkTcTyVarToTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083290"><span class="hs-identifier hs-var">tyvar1</span></a></span><span>
</span><span id="line-711"></span><span>              </span><span class="hs-comment">-- Be sure to zonk here!  Tidying applies to zonked</span><span>
</span><span id="line-712"></span><span>              </span><span class="hs-comment">-- types, so if we don't zonk we may create an</span><span>
</span><span id="line-713"></span><span>              </span><span class="hs-comment">-- ill-kinded type (#14175)</span><span>
</span><span id="line-714"></span><span>            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [TcBinder] -&gt; TcM TidyEnv
</span><a href="#local-6989586621681083310"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681083296"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarEnv Id -&gt; Id -&gt; Id -&gt; VarEnv Id
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681083301"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083297"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083288"><span class="hs-identifier hs-var">tyvar2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681083299"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-715"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-716"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [TcBinder] -&gt; TcM TidyEnv
</span><a href="#local-6989586621681083310"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681083302"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681083301"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TcBinder]
</span><a href="#local-6989586621681083299"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-717"></span><span>
</span><span id="line-718"></span><span class="hs-comment">-- | Get a 'TidyEnv' that includes mappings for all vars free in the given</span><span>
</span><span id="line-719"></span><span class="hs-comment">-- type. Useful when tidying open types.</span><span>
</span><span id="line-720"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcInitOpenTidyEnv"><span class="hs-identifier hs-type">tcInitOpenTidyEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span>
</span><span id="line-721"></span><span id="tcInitOpenTidyEnv"><span class="annot"><span class="annottext">tcInitOpenTidyEnv :: [Id] -&gt; TcM TidyEnv
</span><a href="GHC.Tc.Utils.Env.html#tcInitOpenTidyEnv"><span class="hs-identifier hs-var hs-var">tcInitOpenTidyEnv</span></a></span></span><span> </span><span id="local-6989586621681083284"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083284"><span class="hs-identifier hs-var">tvs</span></a></span></span><span>
</span><span id="line-722"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083283"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681083283"><span class="hs-identifier hs-var">env1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TidyEnv
</span><a href="GHC.Tc.Utils.Env.html#tcInitTidyEnv"><span class="hs-identifier hs-var">tcInitTidyEnv</span></a></span><span>
</span><span id="line-723"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083282"><span class="annot"><span class="annottext">env2 :: TidyEnv
</span><a href="#local-6989586621681083282"><span class="hs-identifier hs-var hs-var">env2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [Id] -&gt; TidyEnv
</span><a href="GHC.Core.TyCo.Tidy.html#tidyFreeTyCoVars"><span class="hs-identifier hs-var">tidyFreeTyCoVars</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681083283"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681083284"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-724"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TcM TidyEnv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681083282"><span class="hs-identifier hs-var">env2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-725"></span><span>
</span><span id="line-726"></span><span>
</span><span id="line-727"></span><span>
</span><span id="line-728"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
             Adding placeholders
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-733"></span><span>
</span><span id="line-734"></span><span id="local-6989586621681084047"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcAddDataFamConPlaceholders"><span class="hs-identifier hs-type">tcAddDataFamConPlaceholders</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LInstDecl"><span class="hs-identifier hs-type">LInstDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084047"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084047"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-735"></span><span class="hs-comment">-- See Note [AFamDataCon: not promoting data family constructors]</span><span>
</span><span id="line-736"></span><span id="tcAddDataFamConPlaceholders"><span class="annot"><span class="annottext">tcAddDataFamConPlaceholders :: forall a. [LInstDecl GhcRn] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcAddDataFamConPlaceholders"><span class="hs-identifier hs-var hs-var">tcAddDataFamConPlaceholders</span></a></span></span><span> </span><span id="local-6989586621681083278"><span class="annot"><span class="annottext">[LInstDecl GhcRn]
</span><a href="#local-6989586621681083278"><span class="hs-identifier hs-var">inst_decls</span></a></span></span><span> </span><span id="local-6989586621681083277"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083277"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-737"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
forall r. [(Name, TcTyThing)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendKindEnvList"><span class="hs-identifier hs-var">tcExtendKindEnvList</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083276"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">PromotionErr -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#APromotionErr"><span class="hs-identifier hs-var">APromotionErr</span></a></span><span> </span><span class="annot"><span class="annottext">PromotionErr
</span><a href="GHC.Tc.Types.html#FamDataConPE"><span class="hs-identifier hs-var">FamDataConPE</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-738"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681083273"><span class="annot"><span class="annottext">LInstDecl GhcRn
</span><a href="#local-6989586621681083273"><span class="hs-identifier hs-var">lid</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[LInstDecl GhcRn]
</span><a href="#local-6989586621681083278"><span class="hs-identifier hs-var">inst_decls</span></a></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681083276"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083276"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LInstDecl GhcRn -&gt; [Name]
</span><a href="#local-6989586621681083272"><span class="hs-identifier hs-var">get_cons</span></a></span><span> </span><span class="annot"><span class="annottext">LInstDecl GhcRn
</span><a href="#local-6989586621681083273"><span class="hs-identifier hs-var">lid</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-739"></span><span>      </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083277"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-740"></span><span>      </span><span class="hs-comment">-- Note [AFamDataCon: not promoting data family constructors]</span><span>
</span><span id="line-741"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-742"></span><span>    </span><span class="hs-comment">-- get_cons extracts the *constructor* bindings of the declaration</span><span>
</span><span id="line-743"></span><span>    </span><span class="annot"><a href="#local-6989586621681083272"><span class="hs-identifier hs-type">get_cons</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#LInstDecl"><span class="hs-identifier hs-type">LInstDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-744"></span><span>    </span><span id="local-6989586621681083272"><span class="annot"><span class="annottext">get_cons :: LInstDecl GhcRn -&gt; [Name]
</span><a href="#local-6989586621681083272"><span class="hs-identifier hs-var hs-var">get_cons</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#TyFamInstD"><span class="hs-identifier hs-type">TyFamInstD</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-745"></span><span>    </span><span class="annot"><a href="#local-6989586621681083272"><span class="hs-identifier hs-var">get_cons</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#DataFamInstD"><span class="hs-identifier hs-type">DataFamInstD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dfid_inst :: forall pass. InstDecl pass -&gt; DataFamInstDecl pass
</span><a href="GHC.Hs.Decls.html#dfid_inst"><span class="hs-identifier hs-var">dfid_inst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083267"><span class="annot"><span class="annottext">DataFamInstDecl GhcRn
</span><a href="#local-6989586621681083267"><span class="hs-identifier hs-var">fid</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataFamInstDecl GhcRn -&gt; [Name]
</span><a href="#local-6989586621681083266"><span class="hs-identifier hs-var">get_fi_cons</span></a></span><span> </span><span class="annot"><span class="annottext">DataFamInstDecl GhcRn
</span><a href="#local-6989586621681083267"><span class="hs-identifier hs-var">fid</span></a></span><span>
</span><span id="line-746"></span><span>    </span><span class="annot"><a href="#local-6989586621681083272"><span class="hs-identifier hs-var">get_cons</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#ClsInstD"><span class="hs-identifier hs-type">ClsInstD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cid_inst :: forall pass. InstDecl pass -&gt; ClsInstDecl pass
</span><a href="GHC.Hs.Decls.html#cid_inst"><span class="hs-identifier hs-var">cid_inst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ClsInstDecl"><span class="hs-identifier hs-type">ClsInstDecl</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cid_datafam_insts :: forall pass. ClsInstDecl pass -&gt; [LDataFamInstDecl pass]
</span><a href="GHC.Hs.Decls.html#cid_datafam_insts"><span class="hs-identifier hs-var">cid_datafam_insts</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083261"><span class="annot"><span class="annottext">[LDataFamInstDecl GhcRn]
</span><a href="#local-6989586621681083261"><span class="hs-identifier hs-var">fids</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-747"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LDataFamInstDecl GhcRn -&gt; [Name])
-&gt; [LDataFamInstDecl GhcRn] -&gt; [Name]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataFamInstDecl GhcRn -&gt; [Name]
</span><a href="#local-6989586621681083266"><span class="hs-identifier hs-var">get_fi_cons</span></a></span><span> </span><span class="annot"><span class="annottext">(DataFamInstDecl GhcRn -&gt; [Name])
-&gt; (LDataFamInstDecl GhcRn -&gt; DataFamInstDecl GhcRn)
-&gt; LDataFamInstDecl GhcRn
-&gt; [Name]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LDataFamInstDecl GhcRn -&gt; DataFamInstDecl GhcRn
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LDataFamInstDecl GhcRn]
</span><a href="#local-6989586621681083261"><span class="hs-identifier hs-var">fids</span></a></span><span>
</span><span id="line-748"></span><span>
</span><span id="line-749"></span><span>    </span><span class="annot"><a href="#local-6989586621681083266"><span class="hs-identifier hs-type">get_fi_cons</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#DataFamInstDecl"><span class="hs-identifier hs-type">DataFamInstDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-750"></span><span>    </span><span id="local-6989586621681083266"><span class="annot"><span class="annottext">get_fi_cons :: DataFamInstDecl GhcRn -&gt; [Name]
</span><a href="#local-6989586621681083266"><span class="hs-identifier hs-var hs-var">get_fi_cons</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#DataFamInstDecl"><span class="hs-identifier hs-type">DataFamInstDecl</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dfid_eqn :: forall pass.
DataFamInstDecl pass -&gt; FamInstEqn pass (HsDataDefn pass)
</span><a href="GHC.Hs.Decls.html#dfid_eqn"><span class="hs-identifier hs-var">dfid_eqn</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Hs.Type.html#HsIB"><span class="hs-identifier hs-type">HsIB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hsib_body :: forall pass thing. HsImplicitBndrs pass thing -&gt; thing
</span><a href="GHC.Hs.Type.html#hsib_body"><span class="hs-identifier hs-var">hsib_body</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-751"></span><span>                  </span><span class="annot"><a href="GHC.Hs.Decls.html#FamEqn"><span class="hs-identifier hs-type">FamEqn</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">feqn_rhs :: forall pass rhs. FamEqn pass rhs -&gt; rhs
</span><a href="GHC.Hs.Decls.html#feqn_rhs"><span class="hs-identifier hs-var">feqn_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#HsDataDefn"><span class="hs-identifier hs-type">HsDataDefn</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dd_cons :: forall pass. HsDataDefn pass -&gt; [LConDecl pass]
</span><a href="GHC.Hs.Decls.html#dd_cons"><span class="hs-identifier hs-var">dd_cons</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083250"><span class="annot"><span class="annottext">[LConDecl GhcRn]
</span><a href="#local-6989586621681083250"><span class="hs-identifier hs-var">cons</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-752"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Located Name -&gt; Name) -&gt; [Located Name] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Located Name -&gt; Name
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">([Located Name] -&gt; [Name]) -&gt; [Located Name] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(LConDecl GhcRn -&gt; [Located Name])
-&gt; [LConDecl GhcRn] -&gt; [Located Name]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConDecl GhcRn -&gt; [Located Name]
</span><a href="GHC.Hs.Decls.html#getConNames"><span class="hs-identifier hs-var">getConNames</span></a></span><span> </span><span class="annot"><span class="annottext">(ConDecl GhcRn -&gt; [Located Name])
-&gt; (LConDecl GhcRn -&gt; ConDecl GhcRn)
-&gt; LConDecl GhcRn
-&gt; [Located Name]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LConDecl GhcRn -&gt; ConDecl GhcRn
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LConDecl GhcRn]
</span><a href="#local-6989586621681083250"><span class="hs-identifier hs-var">cons</span></a></span><span>
</span><span id="line-753"></span><span>
</span><span id="line-754"></span><span>
</span><span id="line-755"></span><span id="local-6989586621681084017"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcAddPatSynPlaceholders"><span class="hs-identifier hs-type">tcAddPatSynPlaceholders</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Binds.html#PatSynBind"><span class="hs-identifier hs-type">PatSynBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084017"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084017"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-756"></span><span class="hs-comment">-- See Note [Don't promote pattern synonyms]</span><span>
</span><span id="line-757"></span><span id="tcAddPatSynPlaceholders"><span class="annot"><span class="annottext">tcAddPatSynPlaceholders :: forall a. [PatSynBind GhcRn GhcRn] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcAddPatSynPlaceholders"><span class="hs-identifier hs-var hs-var">tcAddPatSynPlaceholders</span></a></span></span><span> </span><span id="local-6989586621681083248"><span class="annot"><span class="annottext">[PatSynBind GhcRn GhcRn]
</span><a href="#local-6989586621681083248"><span class="hs-identifier hs-var">pat_syns</span></a></span></span><span> </span><span id="local-6989586621681083247"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083247"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-758"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, TcTyThing)] -&gt; TcM a -&gt; TcM a
forall r. [(Name, TcTyThing)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendKindEnvList"><span class="hs-identifier hs-var">tcExtendKindEnvList</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
IdP GhcRn
</span><a href="#local-6989586621681083246"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">PromotionErr -&gt; TcTyThing
</span><a href="GHC.Tc.Types.html#APromotionErr"><span class="hs-identifier hs-var">APromotionErr</span></a></span><span> </span><span class="annot"><span class="annottext">PromotionErr
</span><a href="GHC.Tc.Types.html#PatSynPE"><span class="hs-identifier hs-var">PatSynPE</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-759"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#PSB"><span class="hs-identifier hs-type">PSB</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">psb_id :: forall idL idR. PatSynBind idL idR -&gt; Located (IdP idL)
</span><a href="GHC.Hs.Binds.html#psb_id"><span class="hs-identifier hs-var">psb_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681083246"><span class="annot"><span class="annottext">IdP GhcRn
</span><a href="#local-6989586621681083246"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[PatSynBind GhcRn GhcRn]
</span><a href="#local-6989586621681083248"><span class="hs-identifier hs-var">pat_syns</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-760"></span><span>       </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083247"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-761"></span><span>
</span><span id="line-762"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#getTypeSigNames"><span class="hs-identifier hs-type">getTypeSigNames</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Binds.html#LSig"><span class="hs-identifier hs-type">LSig</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span>
</span><span id="line-763"></span><span class="hs-comment">-- Get the names that have a user type sig</span><span>
</span><span id="line-764"></span><span id="getTypeSigNames"><span class="annot"><span class="annottext">getTypeSigNames :: [LSig GhcRn] -&gt; RhsNames
</span><a href="GHC.Tc.Utils.Env.html#getTypeSigNames"><span class="hs-identifier hs-var hs-var">getTypeSigNames</span></a></span></span><span> </span><span id="local-6989586621681083241"><span class="annot"><span class="annottext">[LSig GhcRn]
</span><a href="#local-6989586621681083241"><span class="hs-identifier hs-var">sigs</span></a></span></span><span>
</span><span id="line-765"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LSig GhcRn -&gt; RhsNames -&gt; RhsNames)
-&gt; RhsNames -&gt; [LSig GhcRn] -&gt; RhsNames
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">LSig GhcRn -&gt; RhsNames -&gt; RhsNames
</span><a href="#local-6989586621681083240"><span class="hs-identifier hs-var">get_type_sig</span></a></span><span> </span><span class="annot"><span class="annottext">RhsNames
</span><a href="GHC.Types.Name.Set.html#emptyNameSet"><span class="hs-identifier hs-var">emptyNameSet</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig GhcRn]
</span><a href="#local-6989586621681083241"><span class="hs-identifier hs-var">sigs</span></a></span><span>
</span><span id="line-766"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-767"></span><span>    </span><span class="annot"><a href="#local-6989586621681083240"><span class="hs-identifier hs-type">get_type_sig</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LSig"><span class="hs-identifier hs-type">LSig</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html#NameSet"><span class="hs-identifier hs-type">NameSet</span></a></span><span>
</span><span id="line-768"></span><span>    </span><span id="local-6989586621681083240"><span class="annot"><span class="annottext">get_type_sig :: LSig GhcRn -&gt; RhsNames -&gt; RhsNames
</span><a href="#local-6989586621681083240"><span class="hs-identifier hs-var hs-var">get_type_sig</span></a></span></span><span> </span><span id="local-6989586621681083239"><span class="annot"><span class="annottext">LSig GhcRn
</span><a href="#local-6989586621681083239"><span class="hs-identifier hs-var">sig</span></a></span></span><span> </span><span id="local-6989586621681083238"><span class="annot"><span class="annottext">RhsNames
</span><a href="#local-6989586621681083238"><span class="hs-identifier hs-var">ns</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-769"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">LSig GhcRn
</span><a href="#local-6989586621681083239"><span class="hs-identifier hs-var">sig</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-770"></span><span>        </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#TypeSig"><span class="hs-identifier hs-type">TypeSig</span></a></span><span> </span><span class="annot"><span class="annottext">XTypeSig GhcRn
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681083236"><span class="annot"><span class="annottext">[GenLocated SrcSpan (IdP GhcRn)]
</span><a href="#local-6989586621681083236"><span class="hs-identifier hs-var">names</span></a></span></span><span> </span><span class="annot"><span class="annottext">LHsSigWcType GhcRn
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RhsNames -&gt; [Name] -&gt; RhsNames
</span><a href="GHC.Types.Name.Set.html#extendNameSetList"><span class="hs-identifier hs-var">extendNameSetList</span></a></span><span> </span><span class="annot"><span class="annottext">RhsNames
</span><a href="#local-6989586621681083238"><span class="hs-identifier hs-var">ns</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Located Name -&gt; Name) -&gt; [Located Name] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Located Name -&gt; Name
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">[Located Name]
[GenLocated SrcSpan (IdP GhcRn)]
</span><a href="#local-6989586621681083236"><span class="hs-identifier hs-var">names</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-771"></span><span>        </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#PatSynSig"><span class="hs-identifier hs-type">PatSynSig</span></a></span><span> </span><span class="annot"><span class="annottext">XPatSynSig GhcRn
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681083233"><span class="annot"><span class="annottext">[GenLocated SrcSpan (IdP GhcRn)]
</span><a href="#local-6989586621681083233"><span class="hs-identifier hs-var">names</span></a></span></span><span> </span><span class="annot"><span class="annottext">LHsSigType GhcRn
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RhsNames -&gt; [Name] -&gt; RhsNames
</span><a href="GHC.Types.Name.Set.html#extendNameSetList"><span class="hs-identifier hs-var">extendNameSetList</span></a></span><span> </span><span class="annot"><span class="annottext">RhsNames
</span><a href="#local-6989586621681083238"><span class="hs-identifier hs-var">ns</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Located Name -&gt; Name) -&gt; [Located Name] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Located Name -&gt; Name
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">[Located Name]
[GenLocated SrcSpan (IdP GhcRn)]
</span><a href="#local-6989586621681083233"><span class="hs-identifier hs-var">names</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-772"></span><span>        </span><span class="annot"><span class="annottext">LSig GhcRn
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">RhsNames
</span><a href="#local-6989586621681083238"><span class="hs-identifier hs-var">ns</span></a></span><span>
</span><span id="line-773"></span><span>
</span><span id="line-774"></span><span>
</span><span id="line-775"></span><span class="hs-comment">{- Note [AFamDataCon: not promoting data family constructors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
  data family T a
  data instance T Int = MkT
  data Proxy (a :: k)
  data S = MkS (Proxy 'MkT)

Is it ok to use the promoted data family instance constructor 'MkT' in
the data declaration for S (where both declarations live in the same module)?
No, we don't allow this. It *might* make sense, but at least it would mean that
we'd have to interleave typechecking instances and data types, whereas at
present we do data types *then* instances.

So to check for this we put in the TcLclEnv a binding for all the family
constructors, bound to AFamDataCon, so that if we trip over 'MkT' when
type checking 'S' we'll produce a decent error message.

#12088 describes this limitation. Of course, when MkT and S live in
different modules then all is well.

Note [Don't promote pattern synonyms]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We never promote pattern synonyms.

Consider this (#11265):
  pattern A = True
  instance Eq A
We want a civilised error message from the occurrence of 'A'
in the instance, yet 'A' really has not yet been type checked.

Similarly (#9161)
  {-# LANGUAGE PatternSynonyms, DataKinds #-}
  pattern A = ()
  b :: A
  b = undefined
Here, the type signature for b mentions A.  But A is a pattern
synonym, which is typechecked as part of a group of bindings (for very
good reasons; a view pattern in the RHS may mention a value binding).
It is entirely reasonable to reject this, but to do so we need A to be
in the kind environment when kind-checking the signature for B.

Hence tcAddPatSynPlaceholers adds a binding
    A -&gt; APromotionErr PatSynPE
to the environment. Then GHC.Tc.Gen.HsType.tcTyVar will find A in the kind
environment, and will give a 'wrongThingErr' as a result.  But the
lookup of A won't fail.


************************************************************************
*                                                                      *
\subsection{Rules}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-830"></span><span>
</span><span id="line-831"></span><span id="local-6989586621681084005"><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcExtendRules"><span class="hs-identifier hs-type">tcExtendRules</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LRuleDecl"><span class="hs-identifier hs-type">LRuleDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084005"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084005"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-832"></span><span>        </span><span class="hs-comment">-- Just pop the new rules into the EPS and envt resp</span><span>
</span><span id="line-833"></span><span>        </span><span class="hs-comment">-- All the rules come from an interface file, not source</span><span>
</span><span id="line-834"></span><span>        </span><span class="hs-comment">-- Nevertheless, some may be for this module, if we read</span><span>
</span><span id="line-835"></span><span>        </span><span class="hs-comment">-- its interface instead of its source code</span><span>
</span><span id="line-836"></span><span id="tcExtendRules"><span class="annot"><span class="annottext">tcExtendRules :: forall a. [LRuleDecl GhcTc] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#tcExtendRules"><span class="hs-identifier hs-var hs-var">tcExtendRules</span></a></span></span><span> </span><span id="local-6989586621681083231"><span class="annot"><span class="annottext">[LRuleDecl GhcTc]
</span><a href="#local-6989586621681083231"><span class="hs-identifier hs-var">lcl_rules</span></a></span></span><span> </span><span id="local-6989586621681083230"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083230"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-837"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083229"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083229"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-838"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span>
</span><span id="line-839"></span><span>          </span><span id="local-6989586621681083228"><span class="annot"><span class="annottext">env' :: TcGblEnv
</span><a href="#local-6989586621681083228"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083229"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_rules :: [LRuleDecl GhcTc]
</span><a href="GHC.Tc.Types.html#tcg_rules"><span class="hs-identifier hs-var">tcg_rules</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LRuleDecl GhcTc]
</span><a href="#local-6989586621681083231"><span class="hs-identifier hs-var">lcl_rules</span></a></span><span> </span><span class="annot"><span class="annottext">[LRuleDecl GhcTc] -&gt; [LRuleDecl GhcTc] -&gt; [LRuleDecl GhcTc]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; [LRuleDecl GhcTc]
</span><a href="GHC.Tc.Types.html#tcg_rules"><span class="hs-identifier hs-var hs-var">tcg_rules</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083229"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-840"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM a -&gt; TcM a
forall gbl lcl a. gbl -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setGblEnv"><span class="hs-identifier hs-var">setGblEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681083228"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681083230"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-841"></span><span>
</span><span id="line-842"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Meta level
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-849"></span><span>
</span><span id="line-850"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#checkWellStaged"><span class="hs-identifier hs-type">checkWellStaged</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>         </span><span class="hs-comment">-- What the stage check is for</span><span>
</span><span id="line-851"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#ThLevel"><span class="hs-identifier hs-type">ThLevel</span></a></span><span>      </span><span class="hs-comment">-- Binding level (increases inside brackets)</span><span>
</span><span id="line-852"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#ThLevel"><span class="hs-identifier hs-type">ThLevel</span></a></span><span>      </span><span class="hs-comment">-- Use stage</span><span>
</span><span id="line-853"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>       </span><span class="hs-comment">-- Fail if badly staged, adding an error</span><span>
</span><span id="line-854"></span><span id="checkWellStaged"><span class="annot"><span class="annottext">checkWellStaged :: MsgDoc -&gt; ThLevel -&gt; ThLevel -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Tc.Utils.Env.html#checkWellStaged"><span class="hs-identifier hs-var hs-var">checkWellStaged</span></a></span></span><span> </span><span id="local-6989586621681083225"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083225"><span class="hs-identifier hs-var">pp_thing</span></a></span></span><span> </span><span id="local-6989586621681083224"><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083224"><span class="hs-identifier hs-var">bind_lvl</span></a></span></span><span> </span><span id="local-6989586621681083223"><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083223"><span class="hs-identifier hs-var">use_lvl</span></a></span></span><span>
</span><span id="line-855"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083223"><span class="hs-identifier hs-var">use_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">ThLevel -&gt; ThLevel -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083224"><span class="hs-identifier hs-var">bind_lvl</span></a></span><span>         </span><span class="hs-comment">-- OK! Used later than bound</span><span>
</span><span id="line-856"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>                   </span><span class="hs-comment">-- E.g.  \x -&gt; [| $(f x) |]</span><span>
</span><span id="line-857"></span><span>
</span><span id="line-858"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083224"><span class="hs-identifier hs-var">bind_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">ThLevel -&gt; ThLevel -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="GHC.Tc.Types.html#outerLevel"><span class="hs-identifier hs-var">outerLevel</span></a></span><span>      </span><span class="hs-comment">-- GHC restriction on top level splices</span><span>
</span><span id="line-859"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#stageRestrictionError"><span class="hs-identifier hs-var">stageRestrictionError</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083225"><span class="hs-identifier hs-var">pp_thing</span></a></span><span>
</span><span id="line-860"></span><span>
</span><span id="line-861"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                   </span><span class="hs-comment">-- Badly staged</span><span>
</span><span id="line-862"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#failWithTc"><span class="hs-identifier hs-var">failWithTc</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ())
-&gt; MsgDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>                </span><span class="hs-comment">-- E.g.  \x -&gt; $(f x)</span><span>
</span><span id="line-863"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Stage error:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083225"><span class="hs-identifier hs-var">pp_thing</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-864"></span><span>        </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span>   </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is bound at stage&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ThLevel -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083224"><span class="hs-identifier hs-var">bind_lvl</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-865"></span><span>                </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;but used at stage&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ThLevel -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083223"><span class="hs-identifier hs-var">use_lvl</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-866"></span><span>
</span><span id="line-867"></span><span id="local-6989586621681083219"><span class="annot"><a href="GHC.Tc.Utils.Env.html#stageRestrictionError"><span class="hs-identifier hs-type">stageRestrictionError</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083219"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-868"></span><span id="stageRestrictionError"><span class="annot"><span class="annottext">stageRestrictionError :: forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#stageRestrictionError"><span class="hs-identifier hs-var hs-var">stageRestrictionError</span></a></span></span><span> </span><span id="local-6989586621681083218"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083218"><span class="hs-identifier hs-var">pp_thing</span></a></span></span><span>
</span><span id="line-869"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM a
forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#failWithTc"><span class="hs-identifier hs-var">failWithTc</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; TcM a) -&gt; MsgDoc -&gt; TcM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-870"></span><span>    </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC stage restriction:&quot;</span></span><span>
</span><span id="line-871"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThLevel -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681083218"><span class="hs-identifier hs-var">pp_thing</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is used in a top-level splice, quasi-quote, or annotation,&quot;</span></span><span>
</span><span id="line-872"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;and must be imported, not defined locally&quot;</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-873"></span><span>
</span><span id="line-874"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#topIdLvl"><span class="hs-identifier hs-type">topIdLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#ThLevel"><span class="hs-identifier hs-type">ThLevel</span></a></span><span>
</span><span id="line-875"></span><span class="hs-comment">-- Globals may either be imported, or may be from an earlier &quot;chunk&quot;</span><span>
</span><span id="line-876"></span><span class="hs-comment">-- (separated by declaration splices) of this module.  The former</span><span>
</span><span id="line-877"></span><span class="hs-comment">--  *can* be used inside a top-level splice, but the latter cannot.</span><span>
</span><span id="line-878"></span><span class="hs-comment">-- Hence we give the former impLevel, but the latter topLevel</span><span>
</span><span id="line-879"></span><span class="hs-comment">-- E.g. this is bad:</span><span>
</span><span id="line-880"></span><span class="hs-comment">--      x = [| foo |]</span><span>
</span><span id="line-881"></span><span class="hs-comment">--      $( f x )</span><span>
</span><span id="line-882"></span><span class="hs-comment">-- By the time we are processing the $(f x), the binding for &quot;x&quot;</span><span>
</span><span id="line-883"></span><span class="hs-comment">-- will be in the global env, not the local one.</span><span>
</span><span id="line-884"></span><span id="topIdLvl"><span class="annot"><span class="annottext">topIdLvl :: Id -&gt; ThLevel
</span><a href="GHC.Tc.Utils.Env.html#topIdLvl"><span class="hs-identifier hs-var hs-var">topIdLvl</span></a></span></span><span> </span><span id="local-6989586621681083214"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083214"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalId"><span class="hs-identifier hs-var">isLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083214"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="GHC.Tc.Types.html#outerLevel"><span class="hs-identifier hs-var">outerLevel</span></a></span><span>
</span><span id="line-885"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="GHC.Tc.Types.html#impLevel"><span class="hs-identifier hs-var">impLevel</span></a></span><span>
</span><span id="line-886"></span><span>
</span><span id="line-887"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcMetaTy"><span class="hs-identifier hs-type">tcMetaTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-888"></span><span class="hs-comment">-- Given the name of a Template Haskell data type,</span><span>
</span><span id="line-889"></span><span class="hs-comment">-- return the type</span><span>
</span><span id="line-890"></span><span class="hs-comment">-- E.g. given the name &quot;Expr&quot; return the type &quot;Expr&quot;</span><span>
</span><span id="line-891"></span><span id="tcMetaTy"><span class="annot"><span class="annottext">tcMetaTy :: Name -&gt; IOEnv (Env TcGblEnv TcLclEnv) Type
</span><a href="GHC.Tc.Utils.Env.html#tcMetaTy"><span class="hs-identifier hs-var hs-var">tcMetaTy</span></a></span></span><span> </span><span id="local-6989586621681083211"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083211"><span class="hs-identifier hs-var">tc_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-892"></span><span>    </span><span id="local-6989586621681083210"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083210"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM TyCon
</span><a href="GHC.Tc.Utils.Env.html#tcLookupTyCon"><span class="hs-identifier hs-var">tcLookupTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083211"><span class="hs-identifier hs-var">tc_name</span></a></span><span>
</span><span id="line-893"></span><span>    </span><span class="annot"><span class="annottext">Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) Type
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConTy"><span class="hs-identifier hs-var">mkTyConTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681083210"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-894"></span><span>
</span><span id="line-895"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#isBrackStage"><span class="hs-identifier hs-type">isBrackStage</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#ThStage"><span class="hs-identifier hs-type">ThStage</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-896"></span><span id="isBrackStage"><span class="annot"><span class="annottext">isBrackStage :: ThStage -&gt; Bool
</span><a href="GHC.Tc.Utils.Env.html#isBrackStage"><span class="hs-identifier hs-var hs-var">isBrackStage</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#Brack"><span class="hs-identifier hs-type">Brack</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-897"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#isBrackStage"><span class="hs-identifier hs-var">isBrackStage</span></a></span><span> </span><span id="local-6989586621681083207"><span class="annot"><span class="annottext">ThStage
</span><a href="#local-6989586621681083207"><span class="hs-identifier hs-var">_other</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-898"></span><span>
</span><span id="line-899"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                 getDefaultTys
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-906"></span><span>
</span><span id="line-907"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcGetDefaultTys"><span class="hs-identifier hs-type">tcGetDefaultTys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- Default types</span><span>
</span><span id="line-908"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">,</span><span>  </span><span class="hs-comment">-- True &lt;=&gt; Use overloaded strings</span><span>
</span><span id="line-909"></span><span>                         </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- True &lt;=&gt; Use extended defaulting rules</span><span>
</span><span id="line-910"></span><span id="tcGetDefaultTys"><span class="annot"><span class="annottext">tcGetDefaultTys :: TcM ([Type], (Bool, Bool))
</span><a href="GHC.Tc.Utils.Env.html#tcGetDefaultTys"><span class="hs-identifier hs-var hs-var">tcGetDefaultTys</span></a></span></span><span>
</span><span id="line-911"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083206"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681083206"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-912"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083204"><span class="annot"><span class="annottext">ovl_strings :: Bool
</span><a href="#local-6989586621681083204"><span class="hs-identifier hs-var hs-var">ovl_strings</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#xopt"><span class="hs-identifier hs-var">xopt</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#OverloadedStrings"><span class="hs-identifier hs-var">LangExt.OverloadedStrings</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681083206"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-913"></span><span>              </span><span id="local-6989586621681083201"><span class="annot"><span class="annottext">extended_defaults :: Bool
</span><a href="#local-6989586621681083201"><span class="hs-identifier hs-var hs-var">extended_defaults</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#xopt"><span class="hs-identifier hs-var">xopt</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#ExtendedDefaultRules"><span class="hs-identifier hs-var">LangExt.ExtendedDefaultRules</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681083206"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-914"></span><span>                                        </span><span class="hs-comment">-- See also #1974</span><span>
</span><span id="line-915"></span><span>              </span><span id="local-6989586621681083199"><span class="annot"><span class="annottext">flags :: (Bool, Bool)
</span><a href="#local-6989586621681083199"><span class="hs-identifier hs-var hs-var">flags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083204"><span class="hs-identifier hs-var">ovl_strings</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083201"><span class="hs-identifier hs-var">extended_defaults</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-916"></span><span>
</span><span id="line-917"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083198"><span class="annot"><span class="annottext">Maybe [Type]
</span><a href="#local-6989586621681083198"><span class="hs-identifier hs-var">mb_defaults</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn (Maybe [Type])
</span><a href="GHC.Tc.Utils.Monad.html#getDeclaredDefaultTys"><span class="hs-identifier hs-var">getDeclaredDefaultTys</span></a></span><span>
</span><span id="line-918"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe [Type]
</span><a href="#local-6989586621681083198"><span class="hs-identifier hs-var">mb_defaults</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-919"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681083196"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083196"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">([Type], (Bool, Bool)) -&gt; TcM ([Type], (Bool, Bool))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083196"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(Bool, Bool)
</span><a href="#local-6989586621681083199"><span class="hs-identifier hs-var">flags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">;</span><span>
</span><span id="line-920"></span><span>                                </span><span class="hs-comment">-- User-supplied defaults</span><span>
</span><span id="line-921"></span><span>           </span><span class="annot"><span class="annottext">Maybe [Type]
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-922"></span><span>
</span><span id="line-923"></span><span>        </span><span class="hs-comment">-- No use-supplied default</span><span>
</span><span id="line-924"></span><span>        </span><span class="hs-comment">-- Use [Integer, Double], plus modifications</span><span>
</span><span id="line-925"></span><span>        </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083195"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083195"><span class="hs-identifier hs-var">integer_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; IOEnv (Env TcGblEnv TcLclEnv) Type
</span><a href="GHC.Tc.Utils.Env.html#tcMetaTy"><span class="hs-identifier hs-var">tcMetaTy</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="GHC.Builtin.Types.html#integerTyConName"><span class="hs-identifier hs-var">integerTyConName</span></a></span><span>
</span><span id="line-926"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083193"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083193"><span class="hs-identifier hs-var">list_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; IOEnv (Env TcGblEnv TcLclEnv) Type
</span><a href="GHC.Tc.Utils.Env.html#tcMetaTy"><span class="hs-identifier hs-var">tcMetaTy</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="GHC.Builtin.Types.html#listTyConName"><span class="hs-identifier hs-var">listTyConName</span></a></span><span>
</span><span id="line-927"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; IOEnv (Env TcGblEnv TcLclEnv) ()
</span><a href="GHC.Iface.Load.html#checkWiredInTyCon"><span class="hs-identifier hs-var">checkWiredInTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="GHC.Builtin.Types.html#doubleTyCon"><span class="hs-identifier hs-var">doubleTyCon</span></a></span><span>
</span><span id="line-928"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083189"><span class="annot"><span class="annottext">deflt_tys :: [Type]
</span><a href="#local-6989586621681083189"><span class="hs-identifier hs-var hs-var">deflt_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; [Type] -&gt; [Type]
forall {a}. Bool -&gt; [a] -&gt; [a]
</span><a href="#local-6989586621681083188"><span class="hs-identifier hs-var">opt_deflt</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083201"><span class="hs-identifier hs-var">extended_defaults</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#unitTy"><span class="hs-identifier hs-var">unitTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083193"><span class="hs-identifier hs-var">list_ty</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-929"></span><span>                          </span><span class="hs-comment">-- Note [Extended defaults]</span><span>
</span><span id="line-930"></span><span>                          </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083195"><span class="hs-identifier hs-var">integer_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#doubleTy"><span class="hs-identifier hs-var">doubleTy</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-931"></span><span>                          </span><span class="annot"><span class="annottext">[Type] -&gt; [Type] -&gt; [Type]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; [Type] -&gt; [Type]
forall {a}. Bool -&gt; [a] -&gt; [a]
</span><a href="#local-6989586621681083188"><span class="hs-identifier hs-var">opt_deflt</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083204"><span class="hs-identifier hs-var">ovl_strings</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Builtin.Types.html#stringTy"><span class="hs-identifier hs-var">stringTy</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-932"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Type], (Bool, Bool)) -&gt; TcM ([Type], (Bool, Bool))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083189"><span class="hs-identifier hs-var">deflt_tys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(Bool, Bool)
</span><a href="#local-6989586621681083199"><span class="hs-identifier hs-var">flags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-933"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-934"></span><span>    </span><span id="local-6989586621681083188"><span class="annot"><span class="annottext">opt_deflt :: Bool -&gt; [a] -&gt; [a]
</span><a href="#local-6989586621681083188"><span class="hs-identifier hs-var hs-var">opt_deflt</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span id="local-6989586621681083184"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621681083184"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621681083184"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-935"></span><span>    </span><span class="annot"><a href="#local-6989586621681083188"><span class="hs-identifier hs-var">opt_deflt</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">[a]
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-936"></span><span>
</span><span id="line-937"></span><span class="hs-comment">{-
Note [Extended defaults]
~~~~~~~~~~~~~~~~~~~~~
In interactive mode (or with -XExtendedDefaultRules) we add () as the first type we
try when defaulting.  This has very little real impact, except in the following case.
Consider:
        Text.Printf.printf &quot;hello&quot;
This has type (forall a. IO a); it prints &quot;hello&quot;, and returns 'undefined'.  We don't
want the GHCi repl loop to try to print that 'undefined'.  The neatest thing is to
default the 'a' to (), rather than to Integer (which is what would otherwise happen;
and then GHCi doesn't attempt to print the ().  So in interactive mode, we add
() to the list of defaulting types.  See #1200.

Additionally, the list type [] is added as a default specialization for
Traversable and Foldable. As such the default default list now has types of
varying kinds, e.g. ([] :: * -&gt; *)  and (Integer :: *).

************************************************************************
*                                                                      *
\subsection{The InstInfo type}
*                                                                      *
************************************************************************

The InstInfo type summarises the information in an instance declaration

    instance c =&gt; k (t tvs) where b

It is used just for *local* instance decls (not ones from interface files).
But local instance decls includes
        - derived ones
        - generic ones
as well as explicit user written ones.
-}</span><span>
</span><span id="line-970"></span><span>
</span><span id="line-971"></span><span class="hs-keyword">data</span><span> </span><span id="InstInfo"><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-var">InstInfo</span></a></span></span><span> </span><span id="local-6989586621681083996"><span class="annot"><a href="#local-6989586621681083996"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-972"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="InstInfo"><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-var">InstInfo</span></a></span></span><span>
</span><span id="line-973"></span><span>      </span><span class="hs-special">{</span><span> </span><span id="iSpec"><span class="annot"><span class="annottext">forall a. InstInfo a -&gt; ClsInst
</span><a href="GHC.Tc.Utils.Env.html#iSpec"><span class="hs-identifier hs-var hs-var">iSpec</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span>          </span><span class="hs-comment">-- Includes the dfun id</span><span>
</span><span id="line-974"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="iBinds"><span class="annot"><span class="annottext">forall a. InstInfo a -&gt; InstBindings a
</span><a href="GHC.Tc.Utils.Env.html#iBinds"><span class="hs-identifier hs-var hs-var">iBinds</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier hs-type">InstBindings</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083996"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-975"></span><span>      </span><span class="hs-special">}</span><span>
</span><span id="line-976"></span><span>
</span><span id="line-977"></span><span id="local-6989586621681083992"><span class="annot"><a href="GHC.Tc.Utils.Env.html#iDFunId"><span class="hs-identifier hs-type">iDFunId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083992"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DFunId"><span class="hs-identifier hs-type">DFunId</span></a></span></span><span>
</span><span id="line-978"></span><span id="iDFunId"><span class="annot"><span class="annottext">iDFunId :: forall a. InstInfo a -&gt; Id
</span><a href="GHC.Tc.Utils.Env.html#iDFunId"><span class="hs-identifier hs-var hs-var">iDFunId</span></a></span></span><span> </span><span id="local-6989586621681083179"><span class="annot"><span class="annottext">InstInfo a
</span><a href="#local-6989586621681083179"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; Id
</span><a href="GHC.Core.InstEnv.html#instanceDFunId"><span class="hs-identifier hs-var">instanceDFunId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstInfo a -&gt; ClsInst
forall a. InstInfo a -&gt; ClsInst
</span><a href="GHC.Tc.Utils.Env.html#iSpec"><span class="hs-identifier hs-var hs-var">iSpec</span></a></span><span> </span><span class="annot"><span class="annottext">InstInfo a
</span><a href="#local-6989586621681083179"><span class="hs-identifier hs-var">info</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-979"></span><span>
</span><span id="line-980"></span><span class="hs-keyword">data</span><span> </span><span id="InstBindings"><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier hs-var">InstBindings</span></a></span></span><span> </span><span id="local-6989586621681083990"><span class="annot"><a href="#local-6989586621681083990"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-981"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="InstBindings"><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier hs-var">InstBindings</span></a></span></span><span>
</span><span id="line-982"></span><span>      </span><span class="hs-special">{</span><span> </span><span id="ib_tyvars"><span class="annot"><span class="annottext">forall a. InstBindings a -&gt; [Name]
</span><a href="GHC.Tc.Utils.Env.html#ib_tyvars"><span class="hs-identifier hs-var hs-var">ib_tyvars</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- Names of the tyvars from the instance head</span><span>
</span><span id="line-983"></span><span>                               </span><span class="hs-comment">-- that are lexically in scope in the bindings</span><span>
</span><span id="line-984"></span><span>                               </span><span class="hs-comment">-- Must correspond 1-1 with the forall'd tyvars</span><span>
</span><span id="line-985"></span><span>                               </span><span class="hs-comment">-- of the dfun Id.  When typechecking, we are</span><span>
</span><span id="line-986"></span><span>                               </span><span class="hs-comment">-- going to extend the typechecker's envt with</span><span>
</span><span id="line-987"></span><span>                               </span><span class="hs-comment">--     ib_tyvars -&gt; dfun_forall_tyvars</span><span>
</span><span id="line-988"></span><span>
</span><span id="line-989"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="ib_binds"><span class="annot"><span class="annottext">forall a. InstBindings a -&gt; LHsBinds a
</span><a href="GHC.Tc.Utils.Env.html#ib_binds"><span class="hs-identifier hs-var hs-var">ib_binds</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083990"><span class="hs-identifier hs-type">a</span></a></span><span>    </span><span class="hs-comment">-- Bindings for the instance methods</span><span>
</span><span id="line-990"></span><span>
</span><span id="line-991"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="ib_pragmas"><span class="annot"><span class="annottext">forall a. InstBindings a -&gt; [LSig a]
</span><a href="GHC.Tc.Utils.Env.html#ib_pragmas"><span class="hs-identifier hs-var hs-var">ib_pragmas</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Binds.html#LSig"><span class="hs-identifier hs-type">LSig</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083990"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span>      </span><span class="hs-comment">-- User pragmas recorded for generating</span><span>
</span><span id="line-992"></span><span>                                    </span><span class="hs-comment">-- specialised instances</span><span>
</span><span id="line-993"></span><span>
</span><span id="line-994"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="ib_extensions"><span class="annot"><span class="annottext">forall a. InstBindings a -&gt; [Extension]
</span><a href="GHC.Tc.Utils.Env.html#ib_extensions"><span class="hs-identifier hs-var hs-var">ib_extensions</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#Extension"><span class="hs-identifier hs-type">LangExt.Extension</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- Any extra extensions that should</span><span>
</span><span id="line-995"></span><span>                                             </span><span class="hs-comment">-- be enabled when type-checking</span><span>
</span><span id="line-996"></span><span>                                             </span><span class="hs-comment">-- this instance; needed for</span><span>
</span><span id="line-997"></span><span>                                             </span><span class="hs-comment">-- GeneralizedNewtypeDeriving</span><span>
</span><span id="line-998"></span><span>
</span><span id="line-999"></span><span>      </span><span class="hs-special">,</span><span> </span><span id="ib_derived"><span class="annot"><span class="annottext">forall a. InstBindings a -&gt; Bool
</span><a href="GHC.Tc.Utils.Env.html#ib_derived"><span class="hs-identifier hs-var hs-var">ib_derived</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1000"></span><span>           </span><span class="hs-comment">-- True &lt;=&gt; This code was generated by GHC from a deriving clause</span><span>
</span><span id="line-1001"></span><span>           </span><span class="hs-comment">--          or standalone deriving declaration</span><span>
</span><span id="line-1002"></span><span>           </span><span class="hs-comment">--          Used only to improve error messages</span><span>
</span><span id="line-1003"></span><span>      </span><span class="hs-special">}</span><span>
</span><span id="line-1004"></span><span>
</span><span id="line-1005"></span><span id="local-6989586621681083984"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681083169"><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Extension.html#OutputableBndrId"><span class="hs-identifier hs-type">OutputableBndrId</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083984"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1006"></span><span>       </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Extension.html#GhcPass"><span class="hs-identifier hs-type">GhcPass</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083984"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1007"></span><span>    </span><span id="local-6989586621681083166"><span class="annot"><span class="annottext">ppr :: InstInfo (GhcPass a) -&gt; MsgDoc
</span><a href="#local-6989586621681083166"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstInfo (GhcPass a) -&gt; MsgDoc
forall (a :: Pass).
OutputableBndrId a =&gt;
InstInfo (GhcPass a) -&gt; MsgDoc
</span><a href="GHC.Tc.Utils.Env.html#pprInstInfoDetails"><span class="hs-identifier hs-var">pprInstInfoDetails</span></a></span></span><span>
</span><span id="line-1008"></span><span>
</span><span id="line-1009"></span><span id="local-6989586621681083165"><span class="annot"><a href="GHC.Tc.Utils.Env.html#pprInstInfoDetails"><span class="hs-identifier hs-type">pprInstInfoDetails</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Extension.html#OutputableBndrId"><span class="hs-identifier hs-type">OutputableBndrId</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083165"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1010"></span><span>                   </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Extension.html#GhcPass"><span class="hs-identifier hs-type">GhcPass</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083165"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span></span><span>
</span><span id="line-1011"></span><span id="pprInstInfoDetails"><span class="annot"><span class="annottext">pprInstInfoDetails :: forall (a :: Pass).
OutputableBndrId a =&gt;
InstInfo (GhcPass a) -&gt; MsgDoc
</span><a href="GHC.Tc.Utils.Env.html#pprInstInfoDetails"><span class="hs-identifier hs-var hs-var">pprInstInfoDetails</span></a></span></span><span> </span><span id="local-6989586621681083149"><span class="annot"><span class="annottext">InstInfo (GhcPass a)
</span><a href="#local-6989586621681083149"><span class="hs-identifier hs-var">info</span></a></span></span><span>
</span><span id="line-1012"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; ThLevel -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ClsInst -&gt; MsgDoc
</span><a href="GHC.Core.InstEnv.html#pprInstanceHdr"><span class="hs-identifier hs-var">pprInstanceHdr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstInfo (GhcPass a) -&gt; ClsInst
forall a. InstInfo a -&gt; ClsInst
</span><a href="GHC.Tc.Utils.Env.html#iSpec"><span class="hs-identifier hs-var hs-var">iSpec</span></a></span><span> </span><span class="annot"><span class="annottext">InstInfo (GhcPass a)
</span><a href="#local-6989586621681083149"><span class="hs-identifier hs-var">info</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;where&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-1013"></span><span>        </span><span class="annot"><span class="annottext">ThLevel
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstBindings (GhcPass a) -&gt; MsgDoc
forall {id2 :: Pass}.
(OutputableBndr (IdGhcP id2),
 OutputableBndr (IdGhcP (NoGhcTcPass id2)), IsPass id2) =&gt;
InstBindings (GhcPass id2) -&gt; MsgDoc
</span><a href="#local-6989586621681083146"><span class="hs-identifier hs-var">details</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstInfo (GhcPass a) -&gt; InstBindings (GhcPass a)
forall a. InstInfo a -&gt; InstBindings a
</span><a href="GHC.Tc.Utils.Env.html#iBinds"><span class="hs-identifier hs-var hs-var">iBinds</span></a></span><span> </span><span class="annot"><span class="annottext">InstInfo (GhcPass a)
</span><a href="#local-6989586621681083149"><span class="hs-identifier hs-var">info</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1014"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1015"></span><span>    </span><span id="local-6989586621681083146"><span class="annot"><span class="annottext">details :: InstBindings (GhcPass id2) -&gt; MsgDoc
</span><a href="#local-6989586621681083146"><span class="hs-identifier hs-var hs-var">details</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier hs-type">InstBindings</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ib_pragmas :: forall a. InstBindings a -&gt; [LSig a]
</span><a href="GHC.Tc.Utils.Env.html#ib_pragmas"><span class="hs-identifier hs-var">ib_pragmas</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083128"><span class="annot"><span class="annottext">[LSig (GhcPass id2)]
</span><a href="#local-6989586621681083128"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_binds :: forall a. InstBindings a -&gt; LHsBinds a
</span><a href="GHC.Tc.Utils.Env.html#ib_binds"><span class="hs-identifier hs-var">ib_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681083127"><span class="annot"><span class="annottext">LHsBinds (GhcPass id2)
</span><a href="#local-6989586621681083127"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1016"></span><span>      </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Hs.Binds.html#pprDeclList"><span class="hs-identifier hs-var">pprDeclList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsBinds (GhcPass id2) -&gt; [LSig (GhcPass id2)] -&gt; [MsgDoc]
forall (idL :: Pass) (idR :: Pass) (id2 :: Pass).
(OutputableBndrId idL, OutputableBndrId idR,
 OutputableBndrId id2) =&gt;
LHsBindsLR (GhcPass idL) (GhcPass idR)
-&gt; [LSig (GhcPass id2)] -&gt; [MsgDoc]
</span><a href="GHC.Hs.Binds.html#pprLHsBindsForUser"><span class="hs-identifier hs-var">pprLHsBindsForUser</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass id2)
</span><a href="#local-6989586621681083127"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass id2)]
</span><a href="#local-6989586621681083128"><span class="hs-identifier hs-var">p</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1017"></span><span>
</span><span id="line-1018"></span><span id="local-6989586621681083972"><span class="annot"><a href="GHC.Tc.Utils.Env.html#simpleInstInfoClsTy"><span class="hs-identifier hs-type">simpleInstInfoClsTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083972"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-1019"></span><span id="simpleInstInfoClsTy"><span class="annot"><span class="annottext">simpleInstInfoClsTy :: forall a. InstInfo a -&gt; (Class, Type)
</span><a href="GHC.Tc.Utils.Env.html#simpleInstInfoClsTy"><span class="hs-identifier hs-var hs-var">simpleInstInfoClsTy</span></a></span></span><span> </span><span id="local-6989586621681083124"><span class="annot"><span class="annottext">InstInfo a
</span><a href="#local-6989586621681083124"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; ([Id], Class, [Type])
</span><a href="GHC.Core.InstEnv.html#instanceHead"><span class="hs-identifier hs-var">instanceHead</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstInfo a -&gt; ClsInst
forall a. InstInfo a -&gt; ClsInst
</span><a href="GHC.Tc.Utils.Env.html#iSpec"><span class="hs-identifier hs-var hs-var">iSpec</span></a></span><span> </span><span class="annot"><span class="annottext">InstInfo a
</span><a href="#local-6989586621681083124"><span class="hs-identifier hs-var">info</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1020"></span><span>                           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681083122"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681083122"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621681083121"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083121"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681083122"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083121"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1021"></span><span>                           </span><span class="annot"><span class="annottext">([Id], Class, [Type])
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; (Class, Type)
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;simpleInstInfoClsTy&quot;</span></span><span>
</span><span id="line-1022"></span><span>
</span><span id="line-1023"></span><span id="local-6989586621681083969"><span class="annot"><a href="GHC.Tc.Utils.Env.html#simpleInstInfoTy"><span class="hs-identifier hs-type">simpleInstInfoTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083969"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span></span><span>
</span><span id="line-1024"></span><span id="simpleInstInfoTy"><span class="annot"><span class="annottext">simpleInstInfoTy :: forall a. InstInfo a -&gt; Type
</span><a href="GHC.Tc.Utils.Env.html#simpleInstInfoTy"><span class="hs-identifier hs-var hs-var">simpleInstInfoTy</span></a></span></span><span> </span><span id="local-6989586621681083119"><span class="annot"><span class="annottext">InstInfo a
</span><a href="#local-6989586621681083119"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Class, Type) -&gt; Type
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstInfo a -&gt; (Class, Type)
forall a. InstInfo a -&gt; (Class, Type)
</span><a href="GHC.Tc.Utils.Env.html#simpleInstInfoClsTy"><span class="hs-identifier hs-var">simpleInstInfoClsTy</span></a></span><span> </span><span class="annot"><span class="annottext">InstInfo a
</span><a href="#local-6989586621681083119"><span class="hs-identifier hs-var">info</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1025"></span><span>
</span><span id="line-1026"></span><span id="local-6989586621681083965"><span class="annot"><a href="GHC.Tc.Utils.Env.html#simpleInstInfoTyCon"><span class="hs-identifier hs-type">simpleInstInfoTyCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083965"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span></span><span>
</span><span id="line-1027"></span><span>  </span><span class="hs-comment">-- Gets the type constructor for a simple instance declaration,</span><span>
</span><span id="line-1028"></span><span>  </span><span class="hs-comment">-- i.e. one of the form       instance (...) =&gt; C (T a b c) where ...</span><span>
</span><span id="line-1029"></span><span id="simpleInstInfoTyCon"><span class="annot"><span class="annottext">simpleInstInfoTyCon :: forall a. InstInfo a -&gt; TyCon
</span><a href="GHC.Tc.Utils.Env.html#simpleInstInfoTyCon"><span class="hs-identifier hs-var hs-var">simpleInstInfoTyCon</span></a></span></span><span> </span><span id="local-6989586621681083118"><span class="annot"><span class="annottext">InstInfo a
</span><a href="#local-6989586621681083118"><span class="hs-identifier hs-var">inst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TyCon
</span><a href="GHC.Tc.Utils.TcType.html#tcTyConAppTyCon"><span class="hs-identifier hs-var">tcTyConAppTyCon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstInfo a -&gt; Type
forall a. InstInfo a -&gt; Type
</span><a href="GHC.Tc.Utils.Env.html#simpleInstInfoTy"><span class="hs-identifier hs-var">simpleInstInfoTy</span></a></span><span> </span><span class="annot"><span class="annottext">InstInfo a
</span><a href="#local-6989586621681083118"><span class="hs-identifier hs-var">inst</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1030"></span><span>
</span><span id="line-1031"></span><span class="hs-comment">-- | Make a name for the dict fun for an instance decl.  It's an *external*</span><span>
</span><span id="line-1032"></span><span class="hs-comment">-- name, like other top-level names, and hence must be made with</span><span>
</span><span id="line-1033"></span><span class="hs-comment">-- newGlobalBinder.</span><span>
</span><span id="line-1034"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#newDFunName"><span class="hs-identifier hs-type">newDFunName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1035"></span><span id="newDFunName"><span class="annot"><span class="annottext">newDFunName :: Class -&gt; [Type] -&gt; SrcSpan -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#newDFunName"><span class="hs-identifier hs-var hs-var">newDFunName</span></a></span></span><span> </span><span id="local-6989586621681083116"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681083116"><span class="hs-identifier hs-var">clas</span></a></span></span><span> </span><span id="local-6989586621681083115"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083115"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span id="local-6989586621681083114"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083114"><span class="hs-identifier hs-var">loc</span></a></span></span><span>
</span><span id="line-1036"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083113"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083113"><span class="hs-identifier hs-var">is_boot</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Bool
</span><a href="GHC.Tc.Utils.Monad.html#tcIsHsBootOrSig"><span class="hs-identifier hs-var">tcIsHsBootOrSig</span></a></span><span>
</span><span id="line-1037"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083111"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083111"><span class="hs-identifier hs-var">mod</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-1038"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083109"><span class="annot"><span class="annottext">info_string :: String
</span><a href="#local-6989586621681083109"><span class="hs-identifier hs-var hs-var">info_string</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; String
</span><a href="GHC.Types.Name.Occurrence.html#occNameString"><span class="hs-identifier hs-var">occNameString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681083116"><span class="hs-identifier hs-var">clas</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-1039"></span><span>                            </span><span class="annot"><span class="annottext">(Type -&gt; String) -&gt; [Type] -&gt; String
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; String
</span><a href="GHC.Types.Name.Occurrence.html#occNameString"><span class="hs-identifier hs-var">occNameString</span></a></span><span class="annot"><span class="annottext">(OccName -&gt; String) -&gt; (Type -&gt; OccName) -&gt; Type -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span class="annot"><span class="annottext">Type -&gt; OccName
</span><a href="GHC.Tc.Utils.TcType.html#getDFunTyKey"><span class="hs-identifier hs-var">getDFunTyKey</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083115"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-1040"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083105"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681083105"><span class="hs-identifier hs-var">dfun_occ</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(OccSet -&gt; OccName) -&gt; TcM OccName
</span><a href="GHC.Tc.Utils.Monad.html#chooseUniqueOccTc"><span class="hs-identifier hs-var">chooseUniqueOccTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Bool -&gt; OccSet -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkDFunOcc"><span class="hs-identifier hs-var">mkDFunOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083109"><span class="hs-identifier hs-var">info_string</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681083113"><span class="hs-identifier hs-var">is_boot</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1041"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Module -&gt; OccName -&gt; SrcSpan -&gt; TcM Name
forall a b. Module -&gt; OccName -&gt; SrcSpan -&gt; TcRnIf a b Name
</span><a href="GHC.Iface.Env.html#newGlobalBinder"><span class="hs-identifier hs-var">newGlobalBinder</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083111"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681083105"><span class="hs-identifier hs-var">dfun_occ</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083114"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1042"></span><span>
</span><span id="line-1043"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#newFamInstTyConName"><span class="hs-identifier hs-type">newFamInstTyConName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1044"></span><span id="newFamInstTyConName"><span class="annot"><span class="annottext">newFamInstTyConName :: Located Name -&gt; [Type] -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#newFamInstTyConName"><span class="hs-identifier hs-var hs-var">newFamInstTyConName</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681083101"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083101"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681083100"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083100"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681083099"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083099"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OccName -&gt; OccName) -&gt; SrcSpan -&gt; Name -&gt; [[Type]] -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#mk_fam_inst_name"><span class="hs-identifier hs-var">mk_fam_inst_name</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; OccName
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083101"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083100"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681083099"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1045"></span><span>
</span><span id="line-1046"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#newFamInstAxiomName"><span class="hs-identifier hs-type">newFamInstAxiomName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1047"></span><span id="newFamInstAxiomName"><span class="annot"><span class="annottext">newFamInstAxiomName :: Located Name -&gt; [[Type]] -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#newFamInstAxiomName"><span class="hs-identifier hs-var hs-var">newFamInstAxiomName</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681083096"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083096"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681083095"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083095"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681083094"><span class="annot"><span class="annottext">[[Type]]
</span><a href="#local-6989586621681083094"><span class="hs-identifier hs-var">branches</span></a></span></span><span>
</span><span id="line-1048"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OccName -&gt; OccName) -&gt; SrcSpan -&gt; Name -&gt; [[Type]] -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#mk_fam_inst_name"><span class="hs-identifier hs-var">mk_fam_inst_name</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkInstTyCoOcc"><span class="hs-identifier hs-var">mkInstTyCoOcc</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083096"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083095"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">[[Type]]
</span><a href="#local-6989586621681083094"><span class="hs-identifier hs-var">branches</span></a></span><span>
</span><span id="line-1049"></span><span>
</span><span id="line-1050"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#mk_fam_inst_name"><span class="hs-identifier hs-type">mk_fam_inst_name</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#OccName"><span class="hs-identifier hs-type">OccName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#OccName"><span class="hs-identifier hs-type">OccName</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1051"></span><span id="mk_fam_inst_name"><span class="annot"><span class="annottext">mk_fam_inst_name :: (OccName -&gt; OccName) -&gt; SrcSpan -&gt; Name -&gt; [[Type]] -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#mk_fam_inst_name"><span class="hs-identifier hs-var hs-var">mk_fam_inst_name</span></a></span></span><span> </span><span id="local-6989586621681083092"><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="#local-6989586621681083092"><span class="hs-identifier hs-var">adaptOcc</span></a></span></span><span> </span><span id="local-6989586621681083091"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083091"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681083090"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083090"><span class="hs-identifier hs-var">tc_name</span></a></span></span><span> </span><span id="local-6989586621681083089"><span class="annot"><span class="annottext">[[Type]]
</span><a href="#local-6989586621681083089"><span class="hs-identifier hs-var">tyss</span></a></span></span><span>
</span><span id="line-1052"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083088"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083088"><span class="hs-identifier hs-var">mod</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-1053"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083087"><span class="annot"><span class="annottext">info_string :: String
</span><a href="#local-6989586621681083087"><span class="hs-identifier hs-var hs-var">info_string</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; String
</span><a href="GHC.Types.Name.Occurrence.html#occNameString"><span class="hs-identifier hs-var">occNameString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083090"><span class="hs-identifier hs-var">tc_name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-1054"></span><span>                            </span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; String
forall a. [a] -&gt; [[a]] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#intercalate"><span class="hs-identifier hs-var">intercalate</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;|&quot;</span></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681083086"><span class="hs-identifier hs-var">ty_strings</span></a></span><span>
</span><span id="line-1055"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681083085"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681083085"><span class="hs-identifier hs-var">occ</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(OccSet -&gt; OccName) -&gt; TcM OccName
</span><a href="GHC.Tc.Utils.Monad.html#chooseUniqueOccTc"><span class="hs-identifier hs-var">chooseUniqueOccTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; OccSet -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkInstTyTcOcc"><span class="hs-identifier hs-var">mkInstTyTcOcc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083087"><span class="hs-identifier hs-var">info_string</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1056"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Module -&gt; OccName -&gt; SrcSpan -&gt; TcM Name
forall a b. Module -&gt; OccName -&gt; SrcSpan -&gt; TcRnIf a b Name
</span><a href="GHC.Iface.Env.html#newGlobalBinder"><span class="hs-identifier hs-var">newGlobalBinder</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083088"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="#local-6989586621681083092"><span class="hs-identifier hs-var">adaptOcc</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681083085"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083091"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1057"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1058"></span><span>    </span><span id="local-6989586621681083086"><span class="annot"><span class="annottext">ty_strings :: [String]
</span><a href="#local-6989586621681083086"><span class="hs-identifier hs-var hs-var">ty_strings</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Type] -&gt; String) -&gt; [[Type]] -&gt; [String]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; String) -&gt; [Type] -&gt; String
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; String
</span><a href="GHC.Types.Name.Occurrence.html#occNameString"><span class="hs-identifier hs-var">occNameString</span></a></span><span> </span><span class="annot"><span class="annottext">(OccName -&gt; String) -&gt; (Type -&gt; OccName) -&gt; Type -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; OccName
</span><a href="GHC.Tc.Utils.TcType.html#getDFunTyKey"><span class="hs-identifier hs-var">getDFunTyKey</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[[Type]]
</span><a href="#local-6989586621681083089"><span class="hs-identifier hs-var">tyss</span></a></span><span>
</span><span id="line-1059"></span><span>
</span><span id="line-1060"></span><span class="hs-comment">{-
Stable names used for foreign exports and annotations.
For stable names, the name must be unique (see #1533).  If the
same thing has several stable Ids based on it, the
top-level bindings generated must not have the same name.
Hence we create an External name (doesn't change), and we
append a Unique to the string right here.
-}</span><span>
</span><span id="line-1068"></span><span>
</span><span id="line-1069"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#mkStableIdFromString"><span class="hs-identifier hs-type">mkStableIdFromString</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#OccName"><span class="hs-identifier hs-type">OccName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#OccName"><span class="hs-identifier hs-type">OccName</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span>
</span><span id="line-1070"></span><span id="mkStableIdFromString"><span class="annot"><span class="annottext">mkStableIdFromString :: String -&gt; Type -&gt; SrcSpan -&gt; (OccName -&gt; OccName) -&gt; TcM Id
</span><a href="GHC.Tc.Utils.Env.html#mkStableIdFromString"><span class="hs-identifier hs-var hs-var">mkStableIdFromString</span></a></span></span><span> </span><span id="local-6989586621681083083"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083083"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span id="local-6989586621681083082"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083082"><span class="hs-identifier hs-var">sig_ty</span></a></span></span><span> </span><span id="local-6989586621681083081"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083081"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681083080"><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="#local-6989586621681083080"><span class="hs-identifier hs-var">occ_wrapper</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1071"></span><span>    </span><span id="local-6989586621681083079"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681083079"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-1072"></span><span>    </span><span id="local-6989586621681083077"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083077"><span class="hs-identifier hs-var">mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-1073"></span><span>    </span><span id="local-6989586621681083076"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681083076"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; IOEnv (Env TcGblEnv TcLclEnv) FastString
forall (m :: * -&gt; *).
(MonadIO m, HasDynFlags m, HasModule m) =&gt;
String -&gt; String -&gt; m FastString
</span><a href="GHC.Tc.Utils.Env.html#mkWrapperName"><span class="hs-identifier hs-var">mkWrapperName</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stable&quot;</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083083"><span class="hs-identifier hs-var">str</span></a></span><span>
</span><span id="line-1074"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083075"><span class="annot"><span class="annottext">occ :: OccName
</span><a href="#local-6989586621681083075"><span class="hs-identifier hs-var hs-var">occ</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkVarOccFS"><span class="hs-identifier hs-var">mkVarOccFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681083076"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#OccName"><span class="hs-identifier hs-type">OccName</span></a></span><span>
</span><span id="line-1075"></span><span>        </span><span id="local-6989586621681083073"><span class="annot"><span class="annottext">gnm :: Name
</span><a href="#local-6989586621681083073"><span class="hs-identifier hs-var hs-var">gnm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Module -&gt; OccName -&gt; SrcSpan -&gt; Name
</span><a href="GHC.Types.Name.html#mkExternalName"><span class="hs-identifier hs-var">mkExternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681083079"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083077"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="#local-6989586621681083080"><span class="hs-identifier hs-var">occ_wrapper</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681083075"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681083081"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1076"></span><span>        </span><span id="local-6989586621681083071"><span class="annot"><span class="annottext">id :: Id
</span><a href="#local-6989586621681083071"><span class="hs-identifier hs-var hs-var">id</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; Id
</span><a href="GHC.Types.Id.html#mkExportedVanillaId"><span class="hs-identifier hs-var">mkExportedVanillaId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083073"><span class="hs-identifier hs-var">gnm</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681083082"><span class="hs-identifier hs-var">sig_ty</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-1077"></span><span>    </span><span class="annot"><span class="annottext">Id -&gt; TcM Id
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681083071"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1078"></span><span>
</span><span id="line-1079"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#mkStableIdFromName"><span class="hs-identifier hs-type">mkStableIdFromName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#OccName"><span class="hs-identifier hs-type">OccName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#OccName"><span class="hs-identifier hs-type">OccName</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span>
</span><span id="line-1080"></span><span id="mkStableIdFromName"><span class="annot"><span class="annottext">mkStableIdFromName :: Name -&gt; Type -&gt; SrcSpan -&gt; (OccName -&gt; OccName) -&gt; TcM Id
</span><a href="GHC.Tc.Utils.Env.html#mkStableIdFromName"><span class="hs-identifier hs-var hs-var">mkStableIdFromName</span></a></span></span><span> </span><span id="local-6989586621681083069"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083069"><span class="hs-identifier hs-var">nm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Type -&gt; SrcSpan -&gt; (OccName -&gt; OccName) -&gt; TcM Id
</span><a href="GHC.Tc.Utils.Env.html#mkStableIdFromString"><span class="hs-identifier hs-var">mkStableIdFromString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; String
forall a. NamedThing a =&gt; a -&gt; String
</span><a href="GHC.Types.Name.html#getOccString"><span class="hs-identifier hs-var">getOccString</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083069"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1081"></span><span>
</span><span id="line-1082"></span><span id="local-6989586621681083952"><span class="annot"><a href="GHC.Tc.Utils.Env.html#mkWrapperName"><span class="hs-identifier hs-type">mkWrapperName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier hs-type">MonadIO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083952"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#HasDynFlags"><span class="hs-identifier hs-type">HasDynFlags</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083952"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html#HasModule"><span class="hs-identifier hs-type">HasModule</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681083952"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1083"></span><span>              </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681083952"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span></span><span>
</span><span id="line-1084"></span><span id="mkWrapperName"><span class="annot"><span class="annottext">mkWrapperName :: forall (m :: * -&gt; *).
(MonadIO m, HasDynFlags m, HasModule m) =&gt;
String -&gt; String -&gt; m FastString
</span><a href="GHC.Tc.Utils.Env.html#mkWrapperName"><span class="hs-identifier hs-var hs-var">mkWrapperName</span></a></span></span><span> </span><span id="local-6989586621681083049"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083049"><span class="hs-identifier hs-var">what</span></a></span></span><span> </span><span id="local-6989586621681083048"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083048"><span class="hs-identifier hs-var">nameBase</span></a></span></span><span>
</span><span id="line-1085"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681083047"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681083047"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">m DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1086"></span><span>         </span><span id="local-6989586621681083046"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083046"><span class="hs-identifier hs-var">thisMod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">m Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-1087"></span><span>         </span><span class="hs-keyword">let</span><span> </span><span class="hs-comment">-- Note [Generating fresh names for ccall wrapper]</span><span>
</span><span id="line-1088"></span><span>             </span><span id="local-6989586621681083045"><span class="annot"><span class="annottext">wrapperRef :: IORef (ModuleEnv ThLevel)
</span><a href="#local-6989586621681083045"><span class="hs-identifier hs-var hs-var">wrapperRef</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; IORef (ModuleEnv ThLevel)
</span><a href="GHC.Driver.Session.html#nextWrapperNum"><span class="hs-identifier hs-var hs-var">nextWrapperNum</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681083047"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-1089"></span><span>             </span><span id="local-6989586621681083043"><span class="annot"><span class="annottext">pkg :: String
</span><a href="#local-6989586621681083043"><span class="hs-identifier hs-var hs-var">pkg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unit -&gt; String
</span><a href="GHC.Unit.Types.html#unitString"><span class="hs-identifier hs-var">unitString</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; Unit
forall unit. GenModule unit -&gt; unit
</span><a href="GHC.Unit.Types.html#moduleUnit"><span class="hs-identifier hs-var hs-var">moduleUnit</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083046"><span class="hs-identifier hs-var">thisMod</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1090"></span><span>             </span><span id="local-6989586621681083040"><span class="annot"><span class="annottext">mod :: String
</span><a href="#local-6989586621681083040"><span class="hs-identifier hs-var hs-var">mod</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; String
</span><a href="GHC.Unit.Module.Name.html#moduleNameString"><span class="hs-identifier hs-var">moduleNameString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; ModuleName
forall unit. GenModule unit -&gt; ModuleName
</span><a href="GHC.Unit.Types.html#moduleName"><span class="hs-identifier hs-var hs-var">moduleName</span></a></span><span>      </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083046"><span class="hs-identifier hs-var">thisMod</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1091"></span><span>         </span><span id="local-6989586621681083037"><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083037"><span class="hs-identifier hs-var">wrapperNum</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO ThLevel -&gt; m ThLevel
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO ThLevel -&gt; m ThLevel) -&gt; IO ThLevel -&gt; m ThLevel
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (ModuleEnv ThLevel)
-&gt; (ModuleEnv ThLevel -&gt; (ModuleEnv ThLevel, ThLevel))
-&gt; IO ThLevel
forall a b. IORef a -&gt; (a -&gt; (a, b)) -&gt; IO b
</span><a href="../../base/src/GHC.IORef.html#atomicModifyIORef%27"><span class="hs-identifier hs-var">atomicModifyIORef'</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (ModuleEnv ThLevel)
</span><a href="#local-6989586621681083045"><span class="hs-identifier hs-var">wrapperRef</span></a></span><span> </span><span class="annot"><span class="annottext">((ModuleEnv ThLevel -&gt; (ModuleEnv ThLevel, ThLevel)) -&gt; IO ThLevel)
-&gt; (ModuleEnv ThLevel -&gt; (ModuleEnv ThLevel, ThLevel))
-&gt; IO ThLevel
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681083034"><span class="annot"><span class="annottext">ModuleEnv ThLevel
</span><a href="#local-6989586621681083034"><span class="hs-identifier hs-var">mod_env</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-1092"></span><span>             </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083033"><span class="annot"><span class="annottext">num :: ThLevel
</span><a href="#local-6989586621681083033"><span class="hs-identifier hs-var hs-var">num</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ModuleEnv ThLevel -&gt; ThLevel -&gt; Module -&gt; ThLevel
forall a. ModuleEnv a -&gt; a -&gt; Module -&gt; a
</span><a href="GHC.Unit.Module.Env.html#lookupWithDefaultModuleEnv"><span class="hs-identifier hs-var">lookupWithDefaultModuleEnv</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleEnv ThLevel
</span><a href="#local-6989586621681083034"><span class="hs-identifier hs-var">mod_env</span></a></span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083046"><span class="hs-identifier hs-var">thisMod</span></a></span><span>
</span><span id="line-1093"></span><span>                 </span><span id="local-6989586621681083031"><span class="annot"><span class="annottext">mod_env' :: ModuleEnv ThLevel
</span><a href="#local-6989586621681083031"><span class="hs-identifier hs-var hs-var">mod_env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ModuleEnv ThLevel -&gt; Module -&gt; ThLevel -&gt; ModuleEnv ThLevel
forall a. ModuleEnv a -&gt; Module -&gt; a -&gt; ModuleEnv a
</span><a href="GHC.Unit.Module.Env.html#extendModuleEnv"><span class="hs-identifier hs-var">extendModuleEnv</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleEnv ThLevel
</span><a href="#local-6989586621681083034"><span class="hs-identifier hs-var">mod_env</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681083046"><span class="hs-identifier hs-var">thisMod</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083033"><span class="hs-identifier hs-var">num</span></a></span><span class="annot"><span class="annottext">ThLevel -&gt; ThLevel -&gt; ThLevel
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">ThLevel
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-1094"></span><span>             </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleEnv ThLevel
</span><a href="#local-6989586621681083031"><span class="hs-identifier hs-var">mod_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083033"><span class="hs-identifier hs-var">num</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1095"></span><span>         </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083028"><span class="annot"><span class="annottext">components :: [String]
</span><a href="#local-6989586621681083028"><span class="hs-identifier hs-var hs-var">components</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083049"><span class="hs-identifier hs-var">what</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThLevel -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">ThLevel
</span><a href="#local-6989586621681083037"><span class="hs-identifier hs-var">wrapperNum</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083043"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083040"><span class="hs-identifier hs-var">mod</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083048"><span class="hs-identifier hs-var">nameBase</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1096"></span><span>         </span><span class="annot"><span class="annottext">FastString -&gt; m FastString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(FastString -&gt; m FastString) -&gt; FastString -&gt; m FastString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; FastString) -&gt; String -&gt; FastString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String
</span><a href="GHC.Utils.Encoding.html#zEncodeString"><span class="hs-identifier hs-var">zEncodeString</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; String) -&gt; String -&gt; String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String] -&gt; String
forall a. [a] -&gt; [[a]] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#intercalate"><span class="hs-identifier hs-var">intercalate</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:&quot;</span></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681083028"><span class="hs-identifier hs-var">components</span></a></span><span>
</span><span id="line-1097"></span><span>
</span><span id="line-1098"></span><span class="hs-comment">{-
Note [Generating fresh names for FFI wrappers]

We used to use a unique, rather than nextWrapperNum, to distinguish
between FFI wrapper functions. However, the wrapper names that we
generate are external names. This means that if a call to them ends up
in an unfolding, then we can't alpha-rename them, and thus if the
unique randomly changes from one compile to another then we get a
spurious ABI change (#4012).

The wrapper counter has to be per-module, not global, so that the number we end
up using is not dependent on the modules compiled before the current one.
-}</span><span>
</span><span id="line-1111"></span><span>
</span><span id="line-1112"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Errors}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1119"></span><span>
</span><span id="line-1120"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#pprBinders"><span class="hs-identifier hs-type">pprBinders</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-1121"></span><span class="hs-comment">-- Used in error messages</span><span>
</span><span id="line-1122"></span><span class="hs-comment">-- Use quotes for a single one; they look a bit &quot;busy&quot; for several</span><span>
</span><span id="line-1123"></span><span id="pprBinders"><span class="annot"><span class="annottext">pprBinders :: [Name] -&gt; MsgDoc
</span><a href="GHC.Tc.Utils.Env.html#pprBinders"><span class="hs-identifier hs-var hs-var">pprBinders</span></a></span></span><span> </span><span class="hs-special">[</span><span id="local-6989586621681083024"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083024"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083024"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1124"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#pprBinders"><span class="hs-identifier hs-var">pprBinders</span></a></span><span> </span><span id="local-6989586621681083023"><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681083023"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; MsgDoc) -&gt; [Name] -&gt; MsgDoc
forall a. (a -&gt; MsgDoc) -&gt; [a] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#pprWithCommas"><span class="hs-identifier hs-var">pprWithCommas</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681083023"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-1125"></span><span>
</span><span id="line-1126"></span><span class="annot"><a href="GHC.Tc.Utils.Env.html#notFound"><span class="hs-identifier hs-type">notFound</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyThing"><span class="hs-identifier hs-type">TyThing</span></a></span><span>
</span><span id="line-1127"></span><span id="notFound"><span class="annot"><span class="annottext">notFound :: Name -&gt; TcM TyThing
</span><a href="GHC.Tc.Utils.Env.html#notFound"><span class="hs-identifier hs-var hs-var">notFound</span></a></span></span><span> </span><span id="local-6989586621681083021"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083021"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-1128"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681083020"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083020"><span class="hs-identifier hs-var">lcl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcLclEnv
forall gbl lcl. TcRnIf gbl lcl lcl
</span><a href="GHC.Tc.Utils.Monad.html#getLclEnv"><span class="hs-identifier hs-var">getLclEnv</span></a></span><span>
</span><span id="line-1129"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681083019"><span class="annot"><span class="annottext">stage :: ThStage
</span><a href="#local-6989586621681083019"><span class="hs-identifier hs-var hs-var">stage</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLclEnv -&gt; ThStage
</span><a href="GHC.Tc.Types.html#tcl_th_ctxt"><span class="hs-identifier hs-var hs-var">tcl_th_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083020"><span class="hs-identifier hs-var">lcl_env</span></a></span><span>
</span><span id="line-1130"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ThStage
</span><a href="#local-6989586621681083019"><span class="hs-identifier hs-var">stage</span></a></span><span> </span><span class="hs-keyword">of</span><span>   </span><span class="hs-comment">-- See Note [Out of scope might be a staging error]</span><span>
</span><span id="line-1131"></span><span>           </span><span class="annot"><a href="GHC.Tc.Types.html#Splice"><span class="hs-identifier hs-type">Splice</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span>
</span><span id="line-1132"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Builtin.Names.html#isUnboundName"><span class="hs-identifier hs-var">isUnboundName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083021"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM TyThing
forall env a. IOEnv env a
</span><a href="GHC.Data.IOEnv.html#failM"><span class="hs-identifier hs-var">failM</span></a></span><span>  </span><span class="hs-comment">-- If the name really isn't in scope</span><span>
</span><span id="line-1133"></span><span>                                            </span><span class="hs-comment">-- don't report it again (#11941)</span><span>
</span><span id="line-1134"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM TyThing
forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#stageRestrictionError"><span class="hs-identifier hs-var">stageRestrictionError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083021"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1135"></span><span>           </span><span class="annot"><span class="annottext">ThStage
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM TyThing
forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#failWithTc"><span class="hs-identifier hs-var">failWithTc</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; TcM TyThing) -&gt; MsgDoc -&gt; TcM TyThing
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1136"></span><span>                </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span class="hs-special">[</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;GHC internal error:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083021"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-1137"></span><span>                     </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is not in scope during type checking, but it passed the renamer&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-1138"></span><span>                     </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcl_env of environment:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcTypeEnv -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLclEnv -&gt; TcTypeEnv
</span><a href="GHC.Tc.Types.html#tcl_env"><span class="hs-identifier hs-var hs-var">tcl_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681083020"><span class="hs-identifier hs-var">lcl_env</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1139"></span><span>                       </span><span class="hs-comment">-- Take care: printing the whole gbl env can</span><span>
</span><span id="line-1140"></span><span>                       </span><span class="hs-comment">-- cause an infinite loop, in the case where we</span><span>
</span><span id="line-1141"></span><span>                       </span><span class="hs-comment">-- are in the middle of a recursive TyCon/Class group;</span><span>
</span><span id="line-1142"></span><span>                       </span><span class="hs-comment">-- so let's just not print it!  Getting a loop here is</span><span>
</span><span id="line-1143"></span><span>                       </span><span class="hs-comment">-- very unhelpful, because it hides one compiler bug with another</span><span>
</span><span id="line-1144"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-1145"></span><span>
</span><span id="line-1146"></span><span id="local-6989586621681084153"><span class="annot"><a href="GHC.Tc.Utils.Env.html#wrongThingErr"><span class="hs-identifier hs-type">wrongThingErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcTyThing"><span class="hs-identifier hs-type">TcTyThing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681084153"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1147"></span><span class="hs-comment">-- It's important that this only calls pprTcTyThingCategory, which in</span><span>
</span><span id="line-1148"></span><span class="hs-comment">-- turn does not look at the details of the TcTyThing.</span><span>
</span><span id="line-1149"></span><span class="hs-comment">-- See Note [Placeholder PatSyn kinds] in GHC.Tc.Gen.Bind</span><span>
</span><span id="line-1150"></span><span id="wrongThingErr"><span class="annot"><span class="annottext">wrongThingErr :: forall a. String -&gt; TcTyThing -&gt; Name -&gt; TcM a
</span><a href="GHC.Tc.Utils.Env.html#wrongThingErr"><span class="hs-identifier hs-var hs-var">wrongThingErr</span></a></span></span><span> </span><span id="local-6989586621681083013"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083013"><span class="hs-identifier hs-var">expected</span></a></span></span><span> </span><span id="local-6989586621681083012"><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083012"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span id="local-6989586621681083011"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083011"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-1151"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM a
forall a. MsgDoc -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#failWithTc"><span class="hs-identifier hs-var">failWithTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyThing -&gt; MsgDoc
</span><a href="GHC.Tc.Types.html#pprTcTyThingCategory"><span class="hs-identifier hs-var">pprTcTyThingCategory</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyThing
</span><a href="#local-6989586621681083012"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681083011"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-1152"></span><span>                </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;used as a&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681083013"><span class="hs-identifier hs-var">expected</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1153"></span><span>
</span><span id="line-1154"></span><span class="hs-comment">{- Note [Out of scope might be a staging error]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
  x = 3
  data T = MkT $(foo x)

where 'foo' is imported from somewhere.

This is really a staging error, because we can't run code involving 'x'.
But in fact the type checker processes types first, so 'x' won't even be
in the type envt when we look for it in $(foo x).  So inside splices we
report something missing from the type env as a staging error.
See #5752 and #5795.
-}</span><span>
</span><span id="line-1168"></span></pre></body></html>